Created
March 17, 2021 05:03
-
-
Save aryasurya21/6edc13a3de3c36516ce3eecc48653aa3 to your computer and use it in GitHub Desktop.
Updated STATIC_FILES
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
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