Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Created August 4, 2017 14:43
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 matthieu-D/66042f3a030e963591ec3a0e88fcc945 to your computer and use it in GitHub Desktop.
Save matthieu-D/66042f3a030e963591ec3a0e88fcc945 to your computer and use it in GitHub Desktop.
/**
* Check out https://googlechrome.github.io/sw-toolbox/ for
* more info on how to use sw-toolbox to custom configure your service worker.
*/
'use strict';
importScripts('./build/sw-toolbox.js');
self.toolbox.options.cache = {
name: 'ionic-cache'
};
// pre-cache our key assets
self.toolbox.precache(
[
'./build/main.js',
'./build/main.css',
'./build/polyfills.js',
'index.html',
'manifest.json'
]
);
// dynamically cache any other local assets
self.toolbox.router.any('/*', self.toolbox.cacheFirst);
// for any other requests go to the network, cache,
// and then only use that cached resource if your user goes offline
self.toolbox.router.default = self.toolbox.networkFirst;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment