Skip to content

Instantly share code, notes, and snippets.

@aryasurya21
Created March 17, 2021 05:03
Show Gist options
  • Save aryasurya21/6edc13a3de3c36516ce3eecc48653aa3 to your computer and use it in GitHub Desktop.
Save aryasurya21/6edc13a3de3c36516ce3eecc48653aa3 to your computer and use it in GitHub Desktop.
Updated STATIC_FILES
var STATIC_CACHE_CONTAINER = "static_v1"
var STATIC_FILES = [
"/",
"/index.js",
"/index.css",
"https://fonts.googleapis.com/css2?family=Ranchers&display=swap",
"https://fonts.gstatic.com/s/ranchers/v8/zrfm0H3Lx-P2Xvs2ArDfBi8.woff2",
"https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
]
self.addEventListener('install', function(event){
event.waitUntil(
caches.open(STATIC_CACHE_CONTAINER)
.then(function(cache){
cache.addAll(STATIC_FILES)
})
)
})
self.addEventListener('activate', function(event){
console.log("service worker activated", event)
})
self.addEventListener('fetch', function(event){
event.respondWith(
caches.match(event.request)
.then(function(response){
if(response){
return response
}
})
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment