Skip to content

Instantly share code, notes, and snippets.

@konstantinmuenster
Created January 24, 2020 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konstantinmuenster/0cce5920039a734139ba5053a1fd0be4 to your computer and use it in GitHub Desktop.
Save konstantinmuenster/0cce5920039a734139ba5053a1fd0be4 to your computer and use it in GitHub Desktop.
Service Worker Rendering - Install Event
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