Skip to content

Instantly share code, notes, and snippets.

@karimsa
Last active April 28, 2021 04:38
Show Gist options
  • Save karimsa/a7f847dfc777adbd0d19ed9f5cd1bcaf to your computer and use it in GitHub Desktop.
Save karimsa/a7f847dfc777adbd0d19ed9f5cd1bcaf to your computer and use it in GitHub Desktop.
Reset service workers
self.addEventListener('install', function(e) {
self.skipWaiting();
});
self.addEventListener('activate', function(e) {
self.registration.unregister()
.then(function() {
return self.clients.matchAll();
})
.then(function(clients) {
clients.forEach(client => client.navigate(client.url))
})
.then(() => location.reload());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment