Skip to content

Instantly share code, notes, and snippets.

@igara
Created April 11, 2016 08:58
Show Gist options
  • Save igara/985839fa112a977ad23361a5fdafb1d3 to your computer and use it in GitHub Desktop.
Save igara/985839fa112a977ad23361a5fdafb1d3 to your computer and use it in GitHub Desktop.
閲覧しているサイトのServiceWorkerの登録削除とCache APIのキャッシュを全て削除するJSコード ref: http://qiita.com/igara/items/9564008194c74e12551e
navigator.serviceWorker.getRegistrations().then(function(registrations) {
// 登録されているworkerを全て削除する
for(let registration of registrations) {
registration.unregister();
}
});
caches.keys().then(function(keys) {
var promises = [];
// キャッシュストレージを全て削除する
keys.forEach(function(cacheName) {
if (cacheName) {
promises.push(caches.delete(cacheName));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment