Closed jakearchibald closed 10 years ago
I think I'm seeing a bug with this, but not sure if I'm going nuts:
navigator.registerServiceWorker('/assets', 'worker.2.js');
alongside worker.js
.In my head, it should have. Is that right?
It activates if you navigate to /assets/shell.3.html
, which is the first time worker.2.js
needs to process a request.
Currently, if there's an installed worker it's promoted to "active" on the next request it's needed for (https://github.com/jakearchibald/serviceworker-demo/blob/master/server.js#L68). This is spec compliant if the installing worker called replace()
as soon as it installed, which is what we're emulating at the moment.
Activate could (and should) be called sooner, in the hope that it could complete before it holds up any requests. I didn't bother optimising this now as the installed-to-active transfer needs rewritten to bring it up to spec.
Moved lots out of server.js. Could do with a sanity check and code review!