Skip to content

Instantly share code, notes, and snippets.

@Accudio
Created February 2, 2021 08:48
Show Gist options
  • Save Accudio/68f2b1f8b816d9a343d04de1ce06ca78 to your computer and use it in GitHub Desktop.
Save Accudio/68f2b1f8b816d9a343d04de1ce06ca78 to your computer and use it in GitHub Desktop.
Delete all caches from within service-worker
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(allCaches => {
return Promise.all(allCaches.map(cacheToDelete => {
return caches.delete(cacheToDelete);
}));
}).then(() => self.clients.claim())
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment