Skip to content

Implement an HTTP cache #12972

Closed
Closed

Activity

  1. added
    E-very-complex
    on Aug 22, 2016
  2. KiChjang commented on Aug 22, 2016

    @KiChjang
    Contributor

    Is this what http_network_or_cache_fetch would essentially use?

  3. jdm commented on Aug 22, 2016

    @jdm
    MemberAuthor

    Precisely.

  4. ashrwin commented on Aug 24, 2016

    @ashrwin
    Contributor

    I'd like to have a crack at this :)

  5. KiChjang commented on Aug 24, 2016

    @KiChjang
    Contributor

    @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.

  6. jdm commented on Aug 24, 2016

    @jdm
    MemberAuthor

    @ashrko619 I'm not going to stop you from working on it, but I highly recommend discussing your implementation plan here.

  7. ashrwin commented on Aug 26, 2016

    @ashrwin
    Contributor

    @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 :)

  8. KiChjang commented on Dec 12, 2016

    @KiChjang
    Contributor

    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.

  9. jdm commented on Dec 13, 2016

    @jdm
    MemberAuthor

    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.

  10. gterzian commented on Jul 31, 2017

    @gterzian
    Member

    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?

  11. KiChjang commented on Jul 31, 2017

    @KiChjang
    Contributor

    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!

  12. jdm commented on Jul 31, 2017

    @jdm
    MemberAuthor

    @gterzian Working on something like this seems like it would be right up your alley in terms of complexity and standalone-ness :)

  13. gterzian commented on Aug 2, 2017

    @gterzian
    Member

    awesome, thanks! I'll start looking more into this...

  14. gterzian commented on Aug 4, 2017

    @gterzian
    Member

    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:

    1. Do we want the cache to deal with partial responses/entries? In the light of https://tools.ietf.org/html/rfc7234#section-3.1 it seems dealing with partial responses is an optional feature of a cache, and requires supporting "Range" and "Content-Range" headers.
    2. The current fetch code seems to imply a cache design where the initial cache check in "http_network_or_cache_fetch" would return an 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::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.

    Please let me know what you think.

  15. 3 remaining items

  16. gterzian commented on Aug 5, 2017

    @gterzian
    Member

    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!

  17. jdm commented on Aug 7, 2017

    @jdm
    MemberAuthor

    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.

  18. KiChjang commented on Aug 21, 2017

    @KiChjang
    Contributor

    #17521 has landed; @gterzian you may now work on it unhindered!

  19. gterzian commented on Aug 22, 2017

    @gterzian
    Member

    awesome, thanks for letting me know and congrats on landing that one!

  20. gterzian commented on Sep 9, 2017

    @gterzian
    Member

    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...

  21. nox commented on Oct 4, 2017

    @nox
    Contributor

    I think we are going to need this in some sort pretty soon for the media stack.

  22. jdm commented on Oct 4, 2017

    @jdm
    MemberAuthor

    Good thing that #18676 is chugging right along!

  23. added 7 commits that reference this issue on Nov 12, 2017
    f6400d7
    00872de
    fa8ee23
    be675d4
    7886301
    1aa5415
    e2bc0f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-networkE-very-complex

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions