Created
March 1, 2017 20:00
-
-
Save amahdy/70f9d679583b67380b783d7f1c6c2d6b 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.onactivate = function(event) { | |
event.waitUntil( | |
self.clients.claim().then(function() { | |
var currentCacheName = CACHE_NAME + '-v' + CACHE_VERSION; | |
return caches.keys().then(function(cacheNames) { | |
return Promise.all( | |
cacheNames.map(function(cacheName) { | |
if (cacheName.indexOf(CACHE_NAME) == -1) { | |
return; | |
} | |
if (cacheName != currentCacheName) { | |
return caches.delete(cacheName); | |
} | |
}) | |
); | |
}); | |
}) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment