Skip to content

Instantly share code, notes, and snippets.

@gokulkrishh
Last active February 11, 2016 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gokulkrishh/6ae7fdca6de33b334745 to your computer and use it in GitHub Desktop.
Save gokulkrishh/6ae7fdca6de33b334745 to your computer and use it in GitHub Desktop.
Service worker activate event
//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