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
When should implementations serialize caches? #362
Comments
(Is this a duplicate of issue #313 ?) |
If a server gives us
I think it's useful to be able to do that, but I'm not sure it's common. I've been going with:
…although I guess the rename way becomes more useful for full cache replacements outside of the serviceworker update process. |
Done a bit of research around this: Loading a page with Content-Length < actual content length
Loading a page with Content-Length > actual content length
Loading a page with Content-Length > actual content length ending in abrupt server termination
Loading a page with no Content-Length, chunked encoding & abrupt server termination
XHR a page with Content-Length < actual content length
XHR a page with Content-Length > actual content length
XHR a page with Content-Length > actual content length ending in abrupt server termination
XHR a page with no Content-Length, chunked encoding & abrupt server termination
|
Amazing summary, Jake. |
Thanks a lot! ;) |
Useful bit of research. Thank you. One question: Are these results consistent across browser versions or did you just test the latest version of each? |
Only looked at the latest stable versions of each |
cool,how do you test these? |
@SKing7 just a little nodejs server sending the headers & data |
Update: Latest thinking is to resolve on full stream read, allowing for rejection on detectable errors |
Just to clarify, how does this effect a Match() while the Put() stream is still in process? Can a Match() for a request/response pair succeed prior to the Put() promise resolving?
I think my first implementation will have the Match() reject in this case. |
Talked to Gavin, this issue covers rather convoluted edge cases and does not qualify as "impact MVP" |
We'll go with the current thinking. Tracked via crbug.com/392621 for Blink. |
I think we finally settled on this behavior: #573 (comment). (See also #361 (comment)). If there's no more concern, I'd be happy to close the related issues. |
Closing. |
Currently, cache.add() is described in the spec as being placed in the [[RequestToResponseMap]] when the response first resolves. There's no way to use cache.put() earlier than response resolution, since the spec doesn't permit passing a promise to the contructor for the response argument.
When the response resolves is somewhat implementation dependent; but it can be as early as when headers are received for the final, non-redirect response for the request; since the data is in a blob behind a promise, the response can be resolved before the full data is received.
When should a Cache API implementation be fully committed to disk?
A common pattern of use is likely to be that a ServiceWorker creates a new cache, loads a series of resources in to it, and moves the new cache on top of the existing cache as a replacement. Example:
But this rename isn't quite safe, is it? The requests are only guaranteed to have received headers, not bodies, and so if we do the rename, we risk partial/erroneous/missing responses in the renamed cache?
I am left with a few questions:
The text was updated successfully, but these errors were encountered: