-
Notifications
You must be signed in to change notification settings - Fork 501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App does not update because old SW URLs 404 #150
Comments
To summarize, this bug affects browsers that: (1) support service workers and (2) loaded The fix probably involves checking whether the active service worker is the expected one, and unregistering if so (some complications around the initial registration flow, though): const expectedServiceWorker = 'es6-unbundled/service-worker.js'
const isServiceWorker = (path) => navigator.serviceWorker.ready.then(r =>
r.active.scriptURL === `${r.scope}${path}`
);
if (!await isServiceWorker(expectedServiceWorker)) {
// wrong service worker is active, register the new one
} (@jeffposnick, do you have any thoughts on how to safely "move" a service worker from one URL to another?) |
See w3c/ServiceWorker#204 for ideas about resolving this on the spec-level. As of right now, the best practice would be to ship a no-op Or... just move the service worker from |
Given that the URL of the service worker needs to be long-lived (just like site URLs like "/list/mens_outerwear"), I think we need to keep "https://shop.polymer-project.org/service-worker.js" around and use it to import the build-specific SW. We can rewrite an importScripts('es6-bundled/service-worker.js'); This would require support from prpl-server-node. Thoughts @justinfagnani @aomarks @frankiefu ? |
We're thinking that we'll update prpl-server to automatically serve a tiny self-unregistering service worker for any would-be-404 "service-worker.js" URL. This simulates what I think we want from the spec at w3c/ServiceWorker#204. |
This may be another reason to explore producing multiple builds overlayed into the same build output folder - in this case we could look at having a single service-worker, that pre-caches the appropriate build for the browser that loads it. |
https://shop.polymer-project.org/list/mens_outerwear is mostly blank (no products):
(Problem seems to be that
https://shop.polymer-project.org/data/mens_outerwear.json
is 404ing.)The text was updated successfully, but these errors were encountered: