0

I've red in many articles that service worker automatically detects if there's a change in its js (mine is 'service-worker.js') http://www.html5rocks.com/en/tutorials/service-worker/introduction/

I already registered and see the status in chrome://serviceworker-internals/. The problem is whenever i change the service-worker.js, it doesn't detect the change when I go to the scope url (mine is 'localhost/dashboard'). The weird thing is when I visit the service-worker.js (localhost/service-worker.js) , then visit the scope url, it now detects the change and I see 2 service workers in chrome://serviceworker-internals/. One has running status and the other one has 'installed' status. I presume that this is correct but why do i still need to go to the js file?

Is this a server side problem or cache problem? I tried clearing the cache but the problem keeps getting back.

MJ Convento
  • 213
  • 3
  • 8
  • Possible duplicate of [Service worker JavaScript update frequency (every 24 hours?)](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours) – Jeff Posnick Aug 16 '16 at 17:37

1 Answers1

0

If you make a change to your service worker, then reloading the page won't kill the old one and activate the new one.

You need to go to the Service Workers section in the dev tool, and checking 'Update on reload'.

Or go to about:blank and then hard refresh with cmd+r

I suggest you to use Chrome Canary for debugging service workers. Hope it helps.

NickHTTPS
  • 744
  • 4
  • 16