Pwa, service worker and providing update


#1

Hi, coming from sencha, had the habit to deal with deltas between versioning of my app.

Here is what I did

  1. uncomment the code to activate service workers in index.html.

  2. Added a lot of svg images into self.toolbox.precache (…) in service-worker.js

Added the app on desktop on android (pwa) or ios. Go to airplane mode : my PWA works fine (all pages, images, etc…)

changed some words in one page, uploaded the new build.

changed page are not loaded into my PWA.

How can I force update or versioning ?

Thanks


#2

strange, updated this morning, does it have a timer ?


#3

Run it in a https server.

And set it in your service-worker.js:

// dynamically cache any other local assets
self.toolbox.router.any(’/*’, self.toolbox.networkFirst);

// 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;


#4

Are you sure is it not : ???

// dynamically cache any other local assets
self.toolbox.router.any('/*', self.toolbox.cacheFirst);

#5

Well, in my case I was not getting the last version of the app because of cache.

self.toolbox.cacheFirst uses local version, if it exists, instead of check the network for newer resources.

self.toolbox.networkFirst check if there’s a newer version of some resource in the network. It there’s a newer version it downloads the newer version, otherwise keep the cache. If there’s no cache it downloads the resource too. Of course the use of data and network to check for new resource is smaller and faster than download the new resources which keeps the app fast.

So, this way your app will update when you open a new page.

I think you can especify with more details what you want to set as networkfirst resource by replacing the argument ‘/*’ or something like. But I’m not usere exactly how .

More details:
https://googlechrome.github.io/sw-toolbox/api.html#main
https://googlechrome.github.io/sw-toolbox/usage.html#main