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

potential http cache issues with importScripts() #894

Closed
wanderview opened this issue May 9, 2016 · 9 comments
Closed

potential http cache issues with importScripts() #894

wanderview opened this issue May 9, 2016 · 9 comments
Labels
Milestone

Comments

@wanderview
Copy link
Member

wanderview commented May 9, 2016

Currently the spec says to use RequestCache reload when updating the service worker script if its been over 24 hours since the last update check. I don't however, see anything about bypassing the http cache for files fetched for importScripts(). I think this could lead to http cache coherence problems when loading and evaluating a service worker script thats split across multiple files.

Edit: My statement about the default http cache behavior in gecko was not accurate.

@wanderview wanderview added this to the Version 1 milestone May 9, 2016
@jakearchibald
Copy link
Contributor

Hmm, I agree. We should use the same cache mode for importScripts as we do for the service worker script itself.

@wanderview
Copy link
Member Author

Maybe this is something chrome is already doing, but I don't think we do it in firefox right now. Kind of a sharp edge waiting to catch someone.

@jakearchibald
Copy link
Contributor

Pre F2F notes: The reload behaviour in SW avoids lock-in. We don't need it for importScripts requests, since you can cache-bust urls in the SW script, but is this difference a gotcha?

@jakearchibald
Copy link
Contributor

F2F:

  • If the main script is skipping cache, all imported modules should do the same

@wanderview
Copy link
Member Author

Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1290939

Sounds like chrome already does this.

@jungkees
Copy link
Collaborator

jungkees commented Dec 5, 2016

If the main script is skipping cache, all imported modules should do the same

I'd like to double-check this behavior. The main script "skipping cache" is different from the main script "changed". I believe the model has been a service worker version holds until the main script itself is changed. In this proposed change, do we want to include all the to-be-imported-scripts for calculating the byte-by-byte match decision for short-circuiting a registration? Then, if an imported script has been changed, will we see this set of scripts as a different service worker version? Advancing to Install in this case seems weird to me.

@jungkees
Copy link
Collaborator

jungkees commented Dec 5, 2016

Note that in the current spec behavior, the imported scripts are served from the cache without hitting the network once the installation is successfully complete for a service worker version.

@jungkees
Copy link
Collaborator

jungkees commented Dec 6, 2016

Sorry. In my previous two comments, I completely missed this history: #839 (comment). I'll dig into it again with that context and consensus considered.

jungkees added a commit that referenced this issue Dec 12, 2016
This introduces service worker registration's use cache field and its
related APIs: options.useCache to register method and
registration.useCache for ServiceWorkerRegistration objects. This
changes the default cache mode of fetching SW scripts to "no-cache".
After the change, 24 hours limit and job's force bypass cache flag rules
are still enforced. register() method's options value set to
{ useCache: true } re-enables the previous default behavior provided
before this change.

Fixes #893 #894.
@jungkees
Copy link
Collaborator

Closed by 7deb238.

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

No branches or pull requests

3 participants