Skip to content

Instantly share code, notes, and snippets.

@tjoskar
Created March 11, 2017 17:42
Show Gist options
  • Save tjoskar/1b089d9e1347f70bb790b02241ccd216 to your computer and use it in GitHub Desktop.
Save tjoskar/1b089d9e1347f70bb790b02241ccd216 to your computer and use it in GitHub Desktop.
serviceworker-install.js
const staticFilesCache = 'static-files-v1';
const staticFiles = [
'/',
'/index.js',
'/style.css',
'https://fonts.googleapis.com/css?family=Open+Sans'
];
self.addEventListener('install', event => {
const saveCacheFiles = caches.open(staticFilesCache)
.then(cache => cache.addAll(staticFiles));
event.waitUntil(saveCacheFiles);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment