Skip to content

Instantly share code, notes, and snippets.

@ritikrishu
Created March 11, 2018 18:24
Show Gist options
  • Save ritikrishu/72bcf989dcbf2c01843d6265f0c2322e to your computer and use it in GitHub Desktop.
Save ritikrishu/72bcf989dcbf2c01843d6265f0c2322e to your computer and use it in GitHub Desktop.
using cache addAll on Service Worker install
self.addEventListener('install', function (event) {
event.waitUntil(
caches.open('your cache name').then(function (cache) {
return cache.addAll([
'/some-route',
'js/my-app.js',
'css/my-app.css',
'imgs/my-app.png',
'https://fonts.gstatic.com/s/roboto/v15/2UX7WLTfW3W8TclTUvlFyQ.woff',
'https://fonts.gstatic.com/s/roboto/v15/d-6IYplOFocCacKzxwXSOD8E0i7KZn-EPnyo3HZu7kw.woff',
...
]);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment