Re: [w3c/ServiceWorker] Why is it possible to register a service worker that you won't ever be able to remove? (#1258)

> Or maybe I could deploy another version with a service worker that has the only function that deletes all previous cache and unregisters previous service worker, if that's possible?

That's the answer you're looking for! Replace the old service worker with one that unregisters itself:

```js
registration.unregister().then(async () => {
  // optionally, get controlled pages to refresh:
  for (const client of await clients.matchAll()) {
    client.navigate(client.url);
  }
});
```

All you need to do is deploy the above at the same location as the current service worker.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1258#issuecomment-356594087

Received on Wednesday, 10 January 2018 12:59:59 UTC