Repository navigation
Continue http cache work - #18676
Continue http cache work#18676
Conversation
|
Heads up! This PR modifies the following files:
|
|
Ok there is still a lot of work to be done, however I now have all the tests in I would like to ask for initial feedback on one early design choice, relating to "how to plug the cache into fetch". Let me sketch the current design:
I tried a fully sync cache operation first, however the tests were failing and I'm pretty sure it was because since the fetch is async, the cache would simply always miss since the full response hadn't been received yet by the time the second request testing for a cache hit came in. How does the above look? |
0052e73 to
df3f9d6
Compare
| }, | ||
| _ => (), | ||
| let has_no_cache_directive = directives.iter().any(|directive| { | ||
| if let header::CacheDirective::NoCache = *directive { |
There was a problem hiding this comment.
Why does header::CacheDirective::NoCache == *directive not work?
| } | ||
|
|
||
| fn is_no_store_cache(headers: &Headers) -> bool { | ||
| println!("debug headers {:?}", headers); |
There was a problem hiding this comment.
@KiChjang In the context of the http-cache/cc-request.html tests, it seems that the request headers set in the tests don't come through to the headers in the request inside network_or_cache_fetch. It seems that some basic headers are set, but not the ones the test is adding. Could this be a bug in the tests, or is some part of the fetch code dealing with request headers not implemented yet?
"debug headers Headers { Accept: */*"
", Accept-Language: en-US, en; q=0.5"
", Referer: http://web-platform.test:8000/fetch/http-cache/cc-request.html"
", User-Agent: Servo/wptrunner"
", }"
There was a problem hiding this comment.
https://dxr.mozilla.org/servo/rev/04f787dbf9b235bf3af58dc7f3160689cdb2311c/components/script/dom/request.rs#292-343 is the code that is supposed to propagate the headers specified in the test into the network stack.
There was a problem hiding this comment.
thanks, I'll check it out...
There was a problem hiding this comment.
fixed in f4f7b9f
The headers were not being copied from the dom Request to the net Request...
|
I'm going to take more time on Monday, but I'll say that in general your description above looks like what I was expecting. For the purposes of merging the first implementation of the PR, I would like to have a plan for how we'll get to simultaneously updating other cache listeners while the original response is still ongoing, because it will be an important use case for the media stack that we're working towards integrating. |
|
@jdm OK. Do you mean that the media stack would be listening on a channel other than the The fetch thread already does something similar by sending the response chunks over to the devtools in addition to the fetch method, see https://github.com/gterzian/servo/blob/929084c584ccf4513fe7dfb6f65a0a305d831131/components/net/http_loader.rs#L1107 I guess the integration would need to be done as well within the fetch thread, not just the cache? Current the devtool chan is stored on |
|
What I meant is that if a media element starts fetching a 100mb file, then seeks to some other point and causes a new request to retrieve the cached response, we don't want to have to wait until the original request is complete before we service the second request. |
|
@jdm Thanks for the explanation. I'm wondering if this doesn't take us into the territory of range requests and caching partial content... |
|
It definitely does. My goal in this work is to ensure that we think about how those fit in with this design before merging it to ensure that we don't have to fundamentally change things later to support them. |
| request_headers: request.headers | ||
| .iter() | ||
| .filter(|header| { | ||
| match header.name().to_lowercase().as_ref() { |
There was a problem hiding this comment.
I don't think you need the as_ref call here if you have the ref keyword in the line above for header.
There was a problem hiding this comment.
I tried |ref header], it gave
expected type `std::string::String`
found type `&'static str`
and also tried putting match &header.name().to_lowercase(), which would give
expected type `&std::string::String`
found type `&'static str`
|
Ok, regarding integration with the media stack:
Besides this, currently the entire http_cache test suite is passing, with the exception of the partial requests bits. I tried to clean up the code a little bit, still somewhat rough but ready for a first review I guess. I can work on the partial requests next weekend. |
6dbd07c to
251f7da
Compare
|
Amazing! |
215de4d to
698b6cd
Compare
|
I found a couple of subtle bugs, a lot actually relied on the fact that the headers were part of the key, and while that gave us some cache logic "for free", it prevented some edge cases(for example not caching a response with A cache key containing only the url, actually follows the spec more closely: I also realized that the entire body updating via the done channel was unecessary, in fact that code didn't work, and it was hidden by the fact that the headers in the key would prevent a match, so in fact the buggy code was just never called... I do wonder how the response body is propagated without this, perhaps thanks to the call to In any case, switched to using a ServoUrl as cachekey(not stripping fragments yet), and storing a Vec of resources per key. Some tests were only passing because the request headers were different. Also fixed the Vary calculation, again it didn't actually work, but that was hidden by the headers in they key that would prevent matches. Almost all tests are passing again, except a few regarding invalidation, I think I just need to debug the function and adapt it to fit the latest... |
7831544 to
b249f2d
Compare
|
Ok, all tests are passing again... |
b661946 to
7fd61fa
Compare
|
I'm puzzled as to why the unit test |
Continue http cache work <!-- Please describe your changes on the following line: --> Work in progress, and not quite worth a review yet. (Continuation of #4117) TODO - [ ] cache metadata (find some subset of`net_traits::Metadata` that can be shared across threads, it seems the problem is mainly stuff inside `hyper::header` in the `headers` field) - [ ] determine which other fields of a `Response` need to be cached, so a full and valid one can be returned upon a cache hit. - [ ] determine how to best share the cache across fetch threads (inside HttpState like I tried now?) - [ ] Spend more time reading the spec and make sure the cache follows it where it matters. - [ ] Make the current wpt tests pass. - [ ] More... --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #12972 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18676) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-css |
|
Uh oh: |
dcc3adf to
ff62d4f
Compare
|
I had to copy |
ff62d4f to
6196a6e
Compare
|
I think this is fine as it is. |
|
📌 Commit 6196a6e has been approved by |
Continue http cache work <!-- Please describe your changes on the following line: --> Work in progress, and not quite worth a review yet. (Continuation of #4117) TODO - [ ] cache metadata (find some subset of`net_traits::Metadata` that can be shared across threads, it seems the problem is mainly stuff inside `hyper::header` in the `headers` field) - [ ] determine which other fields of a `Response` need to be cached, so a full and valid one can be returned upon a cache hit. - [ ] determine how to best share the cache across fetch threads (inside HttpState like I tried now?) - [ ] Spend more time reading the spec and make sure the cache follows it where it matters. - [ ] Make the current wpt tests pass. - [ ] More... --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #12972 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18676) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
|
Thanks for tackling this work! |
|
Wooo! I added the |
|
@Manishearth great, I can open a new PR to check for the |
Work in progress, and not quite worth a review yet. (Continuation of #4117)
TODO
cache metadata (find some subset of
net_traits::Metadatathat can be shared across threads, it seems the problem is mainly stuff insidehyper::headerin theheadersfield)determine which other fields of a
Responseneed to be cached, so a full and valid one can be returned upon a cache hit.determine how to best share the cache across fetch threads (inside HttpState like I tried now?)
Spend more time reading the spec and make sure the cache follows it where it matters.
Make the current wpt tests pass.
More...
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is