Skip to content

Instantly share code, notes, and snippets.

@jacky810124
Created March 29, 2018 07:11
Show Gist options
  • Select an option

  • Save jacky810124/25753322cd47cb5f17e279b0e21cabbf to your computer and use it in GitHub Desktop.

Select an option

Save jacky810124/25753322cd47cb5f17e279b0e21cabbf to your computer and use it in GitHub Desktop.
PWA Day06 - remove outdate cache
self.addEventListener('activate', function(event) {
event.waitUntil(
caches
.keys()
.then(function(cacheNames) {
return Promise.all(
cacheNames
.filter(function(cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
})
.map(function(cacheName) {
return caches.delete(cacheName)
})
)
})
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment