Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save osvaldasvalutis/bf3215a38e2da43e82db86521aa00c63 to your computer and use it in GitHub Desktop.
Save osvaldasvalutis/bf3215a38e2da43e82db86521aa00c63 to your computer and use it in GitHub Desktop.
const criticalResources = [
'/',
'/offline/',
'/assets/css/main.css',
'/assets/js/main.js'
],
cacheCriticals = () => {
return caches.open(version).then( cache => {
return cache.addAll(criticalResources);
});
};
self.addEventListener('install', event => {
event.waitUntil(
cacheCriticals().then( () => self.skipWaiting())
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment