Last active
December 16, 2020 13:40
-
-
Save scsskid/14e0a334b8dcf0123c32c8dd8741abaf to your computer and use it in GitHub Desktop.
[ServiceWorker Delete Caches which arent in list] src: https://developers.google.com/web/fundamentals/primers/service-workers/#update-a-service-worker #serviceworker
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', function(event) { | |
var cacheAllowlist = ['pages-cache-v1', 'blog-posts-cache-v1']; | |
event.waitUntil( | |
caches.keys().then(function(cacheNames) { | |
return Promise.all( | |
cacheNames.map(function(cacheName) { | |
if (cacheAllowlist.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