Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created September 20, 2017 08:22
Show Gist options
  • Save deanhume/4b7e1f136cbee288cff9f0fc46318fbb to your computer and use it in GitHub Desktop.
Save deanhume/4b7e1f136cbee288cff9f0fc46318fbb to your computer and use it in GitHub Desktop.
Clear Service Worker Cache
if ('serviceWorker' in navigator) {
caches.keys().then(function(cacheNames) {
cacheNames.forEach(function(cacheName) {
caches.delete(cacheName);
});
});
}
@ponceleon
Copy link

same for me thanks

@ghasemi1994
Copy link

thank u , this code work after new release.
i'm using of service worker.

@iShafayet
Copy link

If you're using async/await:

if ('serviceWorker' in navigator) {
  for (const key of await caches.keys()) {
    await caches.delete(key);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment