Last active
February 11, 2016 12:37
-
-
Save gokulkrishh/6ae7fdca6de33b334745 to your computer and use it in GitHub Desktop.
Service worker activate event
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
//Activate event will be triggered once after registering, also used to clean up caches | |
self.addEventListener("activate", function (event) { | |
var cacheWhitelist = ['my-static-files']; | |
event.waitUntil( | |
caches.keys() | |
.then(function (allCaches) { | |
//Check all caches and delete old caches here | |
allCaches.map(function (cacheName) { | |
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