Re: [w3c/ServiceWorker] Does changing updateViaCache mint a new ServiceWorkerRegistration or update them all? (#1189)

Good topic for TPAC :)

> You would get a new service worker version with the new registration. So this would not happen.

Just to confirm, suppose there is an active worker `worker.js` running and updateViaCache is `'all'`. You do `reg = await register('worker.js', { updateViaCache: 'none' });`. `reg.active` would be `worker.js` and `reg.updateViaCache` would be `'none'`, but inside the worker registration.active is `worker.js` and `registration.updateViaCache` is still `all`? That kinda seems surprising.

> So try to treat updateViaCache similar to the script URL. It can be changed via registration, but creates a new registration.

Ah this might be key. In Chromium script URL is just a property on the service worker. So a registration can have multiple script URLs. We don't mint a new registration when you register a worker with a different script URL to the newest worker:

```
reg = await navigator.serviceWorker.register('active.js');
// let it become active and have a client
reg2 = await navigator.serviceWorker.register('waiting.js');
reg == reg2; // true
reg.active.scriptURL;  // 'active.js'
reg.waiting.scriptURL; // 'waiting.js'
```



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1189#issuecomment-329798506

Received on Friday, 15 September 2017 14:28:07 UTC