Created
December 5, 2020 04:40
-
-
Save mp5maker/d7fc63864a9aa71bf287077669868ebc to your computer and use it in GitHub Desktop.
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
self.addEventListener('activate', (event) => { | |
console.log("SW Activate Event: Is in the process") | |
// Google Chrome browseer -> console -> application -> cache -> cache storage | |
const onSuccessCachesKeys = (cacheNames) => { | |
// List of cachenames generated by STATIC_CACHE_VERSION | |
console.log(cacheNames) | |
// Loop through all the keys stored in cache storage | |
return Promise.all( | |
cacheNames.map((cache) => { | |
if (cache !== STATIC_CACHE_VERSION) { | |
console.log(`SW Activate Event: Remove the cache: ${cache}`); | |
return caches.delete(cache) | |
} | |
}) | |
) | |
} | |
event.waitUntil(caches.keys().then(onSuccessCachesKeys)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment