service-worker.js 736 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * Check out https://googlechrome.github.io/sw-toolbox/docs/master/index.html for
  3. * more info on how to use sw-toolbox to custom configure your service worker.
  4. */
  5. 'use strict';
  6. importScripts('./build/sw-toolbox.js');
  7. self.toolbox.options.cache = {
  8. name: 'ionic-cache'
  9. };
  10. // pre-cache our key assets
  11. self.toolbox.precache(
  12. [
  13. './build/main.js',
  14. './build/main.css',
  15. './build/polyfills.js',
  16. 'index.html',
  17. 'manifest.json'
  18. ]
  19. );
  20. // dynamically cache any other local assets
  21. self.toolbox.router.any('/*', self.toolbox.cacheFirst);
  22. // for any other requests go to the network, cache,
  23. // and then only use that cached resource if your user goes offline
  24. self.toolbox.router.default = self.toolbox.networkFirst;