Created
July 26, 2020 19:42
-
-
Save Himachallad/8bfac63d24b9cffc67b47699198b13ac to your computer and use it in GitHub Desktop.
Revisions
-
Himachallad created this gist
Jul 26, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ /** * Activates the new service worker and clean old cache incase of version changes */ self.addEventListener("activate", (event) => { const currentCaches = [UNVARYING_CACHE, VOLATILE]; event.waitUntil( caches .keys() .then((cacheNames) => { return cacheNames.filter( (cacheName) => !currentCaches.includes(cacheName) ); }) .then((cachesToDelete) => { return Promise.all( cachesToDelete.map((cacheToDelete) => { return caches.delete(cacheToDelete); }) ); }) .then(() => self.clients.claim()) ); });