Skip to content
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

Service worker expiration #1480

Closed
TomPradat opened this issue Oct 12, 2019 · 3 comments
Closed

Service worker expiration #1480

TomPradat opened this issue Oct 12, 2019 · 3 comments

Comments

@TomPradat
Copy link

I was wondering if there is some spec about the expiration of a service-worker in the browser. If not this could result in the following problem :

Let's say I decide to create a website and cache all the content with a service-worker (except for the service-worker file) so that the website is available offline.

If someone buy the same domain name later and adds a website without a service-worker, the people that previously went on my website would never see the new website (unless they clear the service-worker by hand). What's more the new owner of the domain name would not even know about it

Linked to https://github.com/mozilla/serviceworker-cookbook/issues/327
PS : I talked about this in #1366 but never got an answer

@TomPradat
Copy link
Author

Ping @jakearchibald @slightlyoff

@jakearchibald
Copy link
Contributor

We talked about removing service workers on 404 in #204 (comment).

If someone buy the same domain name later and adds a website without a service-worker

This isn't a problem for service workers only. It's also an issue with cookies and origin storage. The overall solution is https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data.

If you want to target service workers specifically, requests for service worker scripts are sent with a Service-Worker: script header. Servers could react to that and serve a service worker which uninstalls itself.

We did a stupider version of this on the Chrome Dev Summit website, where any 404 ending in .js serves a self-destructing service worker: https://developer.chrome.com/devsummit/does-not-exist.js

@TomPradat
Copy link
Author

Alright, thank you very much for your answer 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants