Created
January 24, 2020 15:24
-
-
Save konstantinmuenster/0cce5920039a734139ba5053a1fd0be4 to your computer and use it in GitHub Desktop.
Service Worker Rendering - Install Event
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
importScripts('./js/handlebars.min.js'); | |
importScripts('./templates/post.precompiled.js'); | |
var CACHE_NAME = 'cache-v1'; | |
var urlsToCache = [ | |
'/', | |
'/templates/index.precompiled.js', | |
'/post/', | |
'/templates/post.precompiled.js', | |
'/css/style.css', | |
'/js/handlebars.min.js', | |
'/js/main.js', | |
'https://jsonplaceholder.typicode.com/posts' | |
]; | |
self.addEventListener('install', function(event) { | |
console.log("Service Worker Registration", event) | |
event.waitUntil( | |
caches.open(CACHE_NAME) | |
.then(function(cache) { | |
return cache.addAll(urlsToCache); | |
}) | |
.catch(function(err) { | |
return console.log(err); | |
}) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment