Skip to content

Commit

Permalink
Add service worker activation event listener
Browse files Browse the repository at this point in the history
  • Loading branch information
muznyo committed Jan 13, 2024
1 parent 95cbc03 commit 87f598f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@ self.addEventListener('fetch', event => {
return response || fetch(event.request);
})
);
});

self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.filter(cacheName => {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
}).map(cacheName => {
return caches.delete(cacheName);
})
);
})
);
});

0 comments on commit 87f598f

Please sign in to comment.