PWA: code not refreshing in the browser (?)


#1

Hi

I’ve spent around 1 hours fighting with the code to then realize that for some reason the changes where not picked by the browser. Unregistering by hand the service worker did the trick. This is very scary as it means that live applications may not receive updates.

Any idea ?

Thanks


#2

Well, that depends on what your service worker code does. Learning a bit more about service workers is probably a good idea. See e.g. Service Workers: an Introduction


#3

Well, that depends on what your service worker code does.

empty new app created from scratch from the tabs template. Any time that I’ve change code/templates, the browser is reloaded but the changes are not reflected…

indeed :wink:


#4

Can you replicate it in a new project and submit to Ionic team?


#5

This is actually something they changed very recently: templates now use the sw-toolbox library.

Before they used this service-worker.js code that says

// This sample illustrates an aggressive approach to caching, in which every valid response is
// cached and every request is first checked against the cache.

That’s probably what you’re using, so you don’t see updates because it’s always using cached files. Unless you increase the CACHE_VERSION number defined at the top of that file.


#6

Can you replicate it in a new project and submit to Ionic team?

While creating a new app, and doing diff with the problematic one, I’ve seen the problem: my fault, I did something stupid, trying to read a local file (the error didn’t help thought ). Now it works.

Thanks @mirkonasato and @vchauhan


#7

Hi sebastianovide, what exactly do you mean reading a local file?
I have have the same issue.