3

I was very cautious about adding a service worker to my PWA that would cache all my files. I tried to implement a system that would always call the server to get a "version" file so that when that "version" file updated, the cache would be cleared.

However, something didn't work correctly, and now the clients no longer call the server at all, since they have the files they need. This is perfect for offline use! But those clients will never call the server again so when I update the site to fix the problem (which I have done), they do not get the update!

Any suggestions on how I can connect with those clients again?

Glen Little
  • 6,951
  • 4
  • 46
  • 68
  • 2
    Possible duplicate of [How can I remove a buggy service worker, or implement a "kill switch"?](https://stackoverflow.com/questions/33986976/how-can-i-remove-a-buggy-service-worker-or-implement-a-kill-switch) – Jeff Posnick Jun 19 '17 at 19:16
  • The linked question is a good discussion of this issue, but doesn't give a good answer to this question. There may not be a way to fix this other than to wait for a while, or somehow communicate with your website users via other channels! – Glen Little Jun 19 '17 at 22:24

1 Answers1

6

The easiest thing for you to do is deploy a change to your service worker code. In that version clear your cache and remove the buggy code. Don't worry this happens a lot when you start working with service worker caching. :)

Chris Love
  • 3,740
  • 1
  • 19
  • 16
  • 1
    But... there is no way to deploy a change because the clients are not coming back for updates! – Glen Little Jun 19 '17 at 22:21
  • 5
    no if you change the service worker the browser will check for the new version. The longest latency you can have is 24 hours. For example if your service worker Cache-Control header is 1 year, the browser will check as soon as the user visits the site after 24 hours. If there is a new version it will load that version. If your Cache-Control is 1 hour then the browser will check for a new version 1 hour later. – Chris Love Jun 20 '17 at 01:49
  • 1
    Good to know. Thanks! – Glen Little Jun 20 '17 at 05:25