Created
October 11, 2017 11:07
-
-
Save aofleejay/45fc9527ce29a8831daef738541a3c59 to your computer and use it in GitHub Desktop.
Clear old cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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