You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ashrko619 Are you sure? I don't think this issue is good for a new contributor. You need to be familiar with the entire Fetch infrastructure and caching.
@KiChjang@jdm I went over the code and the specifications. It looks a bit more complicated than what I thought. I will work on the easy and less-easy issues for now :). I ll keep an eye on this issue and see if I can contribute something to it down the line :)
We can and should be smarter about our caching strategy. We should create a HashableRequest structure for the cache hashmap key which contains:
the request URL (stripped of any fragment)
the request headers
and implements Hash by hashing these together. The values of the hashmap should be the complete Response object that would otherwise be obtained by fetching the request.
I've been sort of dreaming of taking on this one... 😄
What's the current status? I'm assuming this is a large project, yet a fairly standalone one, that wouldn't have too many opportunities to block on other issues, is that correct?
When I look at @jdm previous work, it seems that, when it was available(which was in all cases but CacheOperationResult::Uncacheable), the cache was positioned to be the 'consumer facing' source of response data, by which I mean that even in the case of a new cache entry, the data coming in via the network would first be fed to the cache, copied into the new entry, and it was the cache would send it on to the final consumer. See process_payload.
Conversely, in the case of an existing complete or partial entry, it was also the cache that would be responsible for sending the complete or partial data to the final consumer over a channel, see for example send_complete_entry.
After reading the spec and the current fetch code, I tend towards a design that would only handle complete requests for now and look something like:
A. a cache check inside "http_network_or_cache_fetch", simply passing the net_traits::request::Request to the cache(I think it contains the info required to compute a cache key), and returning either a complete net_traits::response::Response or none.
B. a preliminary cache update in "http_network_fetch"(again by passing the request to the cache) around here. At the point, if the response body matches ResponseBody::Done, the response can be cached readily, if it is ResponseBody::Receiving, the entry can be created but it isn't usable yet.
C. A channel to be used by the fetch worker thread to update the cache entry whose body is still receiving data. Once the body is set to ResponseBody::Done, the cache entry becomes available for a fetch as per A.
D. A cache entry itself would be similar to the previous design(net_traits::Metadata, a Vec for the body, and info on expiration). I guess it would need one more "available" boolean.
In summary, my main point is that I would skip the 'Pending resource' part for now, and start with a cache that only returns complete responses or None.
I agree with all of your conclusions. Having any cache at all seems like a bigger improvement than ensuring that we can return in-progress cache entries instead of making separate requests.
Sorry for the delay in getting started, I was busy with other things last couple of weeks, still committed to this one though, I'll try to take a first stab asap...
Activity
KiChjang commentedon Aug 22, 2016
Is this what http_network_or_cache_fetch would essentially use?
jdm commentedon Aug 22, 2016
Precisely.
ashrwin commentedon Aug 24, 2016
I'd like to have a crack at this :)
KiChjang commentedon Aug 24, 2016
@ashrko619 Are you sure? I don't think this issue is good for a new contributor. You need to be familiar with the entire Fetch infrastructure and caching.
jdm commentedon Aug 24, 2016
@ashrko619 I'm not going to stop you from working on it, but I highly recommend discussing your implementation plan here.
ashrwin commentedon Aug 26, 2016
@KiChjang @jdm I went over the code and the specifications. It looks a bit more complicated than what I thought. I will work on the easy and less-easy issues for now :). I ll keep an eye on this issue and see if I can contribute something to it down the line :)
KiChjang commentedon Dec 12, 2016
I haven't read the spec at all yet, but my initial thoughts were to copy what CookieStorage does and iterate the design over this prototype.
jdm commentedon Dec 13, 2016
We can and should be smarter about our caching strategy. We should create a HashableRequest structure for the cache hashmap key which contains:
and implements Hash by hashing these together. The values of the hashmap should be the complete Response object that would otherwise be obtained by fetching the request.
gterzian commentedon Jul 31, 2017
I've been sort of dreaming of taking on this one... 😄
What's the current status? I'm assuming this is a large project, yet a fairly standalone one, that wouldn't have too many opportunities to block on other issues, is that correct?
KiChjang commentedon Jul 31, 2017
I was planning on taking this, but I have a couple of pull requests that I have to follow before I can work on it. Feel free to work on this!
jdm commentedon Jul 31, 2017
@gterzian Working on something like this seems like it would be right up your alley in terms of complexity and standalone-ness :)
gterzian commentedon Aug 2, 2017
awesome, thanks! I'll start looking more into this...
gterzian commentedon Aug 4, 2017
Ok so couple of questions...
When I look at @jdm previous work, it seems that, when it was available(which was in all cases but
CacheOperationResult::Uncacheable), the cache was positioned to be the 'consumer facing' source of response data, by which I mean that even in the case of a new cache entry, the data coming in via the network would first be fed to the cache, copied into the new entry, and it was the cache would send it on to the final consumer. See process_payload.Conversely, in the case of an existing complete or partial entry, it was also the cache that would be responsible for sending the complete or partial data to the final consumer over a channel, see for example send_complete_entry.
Obviously the fetch and resource code has changed a lot since, and after starting to do some housekeeping on the types used(https://github.com/gterzian/servo/tree/continue_http_cache_work), I realized that we perhaps first need to answer a few high-level design questions:
Option<Response>, and only invokes "http_network_fetch" when that option is none. In general it seems to tend towards putting the cache somewhat "behind" the fetch code, and not allowing it to directly update consumers.After reading the spec and the current fetch code, I tend towards a design that would only handle complete requests for now and look something like:
A. a cache check inside "http_network_or_cache_fetch", simply passing the
net_traits::request::Requestto the cache(I think it contains the info required to compute a cache key), and returning either a completenet_traits::response::Responseor none.B. a preliminary cache update in "http_network_fetch"(again by passing the request to the cache) around here. At the point, if the response body matches
ResponseBody::Done, the response can be cached readily, if it isResponseBody::Receiving, the entry can be created but it isn't usable yet.C. A channel to be used by the fetch worker thread to update the cache entry whose body is still receiving data. Once the body is set to
ResponseBody::Done, the cache entry becomes available for a fetch as per A.D. A cache entry itself would be similar to the previous design(net_traits::Metadata, a Vec for the body, and info on expiration). I guess it would need one more "available" boolean.
In summary, my main point is that I would skip the 'Pending resource' part for now, and start with a cache that only returns complete responses or None.
Please let me know what you think.
3 remaining items
gterzian commentedon Aug 5, 2017
Ok I see, I'll just work on the cache internals in the meantime and keep an eye out on that PR, thanks for the heads-up!
jdm commentedon Aug 7, 2017
I agree with all of your conclusions. Having any cache at all seems like a bigger improvement than ensuring that we can return in-progress cache entries instead of making separate requests.
KiChjang commentedon Aug 21, 2017
#17521 has landed; @gterzian you may now work on it unhindered!
gterzian commentedon Aug 22, 2017
awesome, thanks for letting me know and congrats on landing that one!
gterzian commentedon Sep 9, 2017
Sorry for the delay in getting started, I was busy with other things last couple of weeks, still committed to this one though, I'll try to take a first stab asap...
nox commentedon Oct 4, 2017
I think we are going to need this in some sort pretty soon for the media stack.
jdm commentedon Oct 4, 2017
Good thing that #18676 is chugging right along!
Auto merge of #18676 - gterzian:continue_http_cache_work, r=<try>
Auto merge of #18676 - gterzian:continue_http_cache_work, r=<try>
Auto merge of #18676 - gterzian:continue_http_cache_work, r=<try>
Auto merge of #18676 - gterzian:continue_http_cache_work, r=<try>
Auto merge of #18676 - gterzian:continue_http_cache_work, r=<try>
Auto merge of #18676 - gterzian:continue_http_cache_work, r=jdm
Auto merge of #18676 - gterzian:continue_http_cache_work, r=jdm