Skip to content

Instantly share code, notes, and snippets.

@ritikrishu
Created March 11, 2018 23:41
Show Gist options
  • Save ritikrishu/4f9e47cea551e5b40b10134709938b18 to your computer and use it in GitHub Desktop.
Save ritikrishu/4f9e47cea551e5b40b10134709938b18 to your computer and use it in GitHub Desktop.
add all static content to cache on app update
const staticResourcesAndPath = [
'/skeleton',
'js/main.js',
'css/main.css',
'imgs/icon.png',
'https://fonts.gstatic.com/s/roboto/v15/2UX7WLTfW3W8TclTUvlFyQ.woff',
'https://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOD8E0i7KZn-EPnyo3HZu7kw.woff'
];
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open('myStaticCacheName').then(function (cache) {
return cache.addAll(staticResourcesAndPath);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment