Skip to content

Instantly share code, notes, and snippets.

@niksmac
Created June 3, 2021 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save niksmac/d80452d0a94acb5473c547f2247f13ea to your computer and use it in GitHub Desktop.
Save niksmac/d80452d0a94acb5473c547f2247f13ea to your computer and use it in GitHub Desktop.
Clear service worker cache from browser
caches.keys().then(function (cachesNames) {
console.log("Delete " + document.defaultView.location.origin + " caches");
return Promise.all(cachesNames.map(function (cacheName) {
return caches.delete(cacheName).then(function () {
console.log("Cache with name " + cacheName + " is deleted");
});
}))
}).then(function () {
console.log("All " + document.defaultView.location.origin + " caches are deleted");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment