-
-
Save ankitamasand/346b7c29515ff316180f8f7c2683bbaa to your computer and use it in GitHub Desktop.
This file contains 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) => { | |
let cacheWhitelist = ['products-v2'] // products-v2 is the name of the new cache | |
event.waitUntil( | |
caches.keys().then (cacheNames => { | |
return Promise.all( | |
cacheNames.map( cacheName => { | |
/* Deleting all the caches except the ones that are in cacheWhitelist array */ | |
if (cacheWhitelist.indexOf(cacheName) === -1) { | |
return caches.delete(cacheName) | |
} | |
}) | |
) | |
}) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment