I am using a service worker with the sw-toolbox library . My PWA caches everything except API requests (images, css, js, html). But what if some files are changed someday. Or what if service-worker.js is changed. How should an application know about file changes?
My service-worker.js:
'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;
I do not know what is the usual cache update method in PWA. Perhaps PWA should send an AJAX request in the background and check the user interface version?
javascript service-worker ionic3
Ildar
source share