Skip to content

Commit

Permalink
new attempt to remove service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
agix committed May 2, 2022
1 parent 86d6a35 commit c4fd960
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions public/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
if (window.navigator && navigator.serviceWorker) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
for (let registration of registrations) {
registration.unregister();
}
});
}

if ('caches' in window) {
caches.keys().then(function(keyList) {
return Promise.all(
keyList.map(function(key) {
return caches.delete(key);
})
);
});
}

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));
});
});

0 comments on commit c4fd960

Please sign in to comment.