-
-
Save ankitamasand/5b7480a705cdd057a177fb449365a841 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.addEventListener('install', (event) => { | |
let CACHE_NAME = 'xyz-cache' | |
let urlsToCache = [ | |
'/', | |
'/styles/main.css', | |
'/scripts/bundle.js' | |
] | |
event.waitUntil( | |
/* open method available on caches, takes in the name of cache as the first paramter. It returns a promise that resolves to the instance of cache | |
All the above URLS can be added to cache using the addAll method. */ | |
caches.open(CACHE_NAME) | |
.then (cache => cache.addAll(urlsToCache)) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment