Skip to content

Instantly share code, notes, and snippets.

@mp5maker
Last active December 5, 2020 04:36
Show Gist options
  • Save mp5maker/7a63602c74dd4b97467e54d414a877a6 to your computer and use it in GitHub Desktop.
Save mp5maker/7a63602c74dd4b97467e54d414a877a6 to your computer and use it in GitHub Desktop.
Service Worker Install Section
self.addEventListener('install', function(event) {
console.log(caches)
console.log("SW Install Event: Is in the process");
const onSuccessCachesOpen = (cache) => {
console.log(cache)
console.log("SW Install Event: Successfully opened the cache and add the cache list");
return cache.addAll(CACHE_LIST)
}
// Works like async/await
event.waitUntil(
// caches is a global variable inside the service workers file [readily available]
caches.open(STATIC_CACHE_VERSION).then(onSuccessCachesOpen)
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment