Skip to content

Instantly share code, notes, and snippets.

@aofleejay
Created October 11, 2017 11:07
Show Gist options
  • Save aofleejay/45fc9527ce29a8831daef738541a3c59 to your computer and use it in GitHub Desktop.
Save aofleejay/45fc9527ce29a8831daef738541a3c59 to your computer and use it in GitHub Desktop.
Clear old cache
self.addEventListener('activate', event => {
const cacheWhitelist = [CACHE_KEY]
event.waitUntil(
caches.keys().then(keyList => {
return Promise.all(keyList.map(function(key) {
if (cacheWhitelist.indexOf(key) === -1) {
return caches.delete(key)
}
}))
})
)
return self.clients.claim()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment