fix: add new service worker (#2971)
This commit is contained in:
parent
2f4ee35561
commit
4d95c17e86
4 changed files with 31 additions and 1 deletions
24
public/sw.js
Normal file
24
public/sw.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
// DON'T REMOVE THIS FILE: IT IS THE OLD sw.js
|
||||
self.addEventListener('install', (e) => {
|
||||
self.skipWaiting();
|
||||
});
|
||||
self.addEventListener('activate', (e) => {
|
||||
self.registration.unregister()
|
||||
.then(() => self.clients.matchAll())
|
||||
.then((clients) => {
|
||||
clients.forEach((client) => {
|
||||
if (client instanceof WindowClient)
|
||||
client.navigate(client.url);
|
||||
});
|
||||
return Promise.resolve();
|
||||
})
|
||||
.then(() => {
|
||||
self.caches.keys().then((cacheNames) => {
|
||||
Promise.all(
|
||||
cacheNames.map((cacheName) => {
|
||||
return self.caches.delete(cacheName);
|
||||
})
|
||||
);
|
||||
})
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue