Update sw.js

This commit is contained in:
mihaisc 2022-08-02 14:12:52 +03:00 committed by GitHub
parent 3c32812292
commit cb4b436d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 4 deletions

21
sw.js
View File

@ -1,11 +1,24 @@
self.addEventListener('install', function(e) {
console.log('script install')
self.skipWaiting();
});
self.addEventListener('activate', function(e) {
console.log('script activate')
self.registration.unregister()
self.addEventListener("activate", function (event) {
event.waitUntil(
caches.keys().then(function (cacheNames) {
return Promise.all(
cacheNames
.filter(function (cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
})
.map(function (cacheName) {
return caches.delete(cacheName);
})
);
})
);
self.registration.unregister()
.then(function() {
return self.clients.matchAll();
})