HTTP client with cache?

Is there a caching HTTP client for Rust?

I've rolled out my own naive if !cached_result.exists() {request.get()}, but it should do expiry, revalidation, etc.

3 Likes

I guess I'll have to write one. Let me know if you want to help :slight_smile:

2 Likes

I mean I guess at least servo has one? :stuck_out_tongue:

1 Like

It depends, most often you probably don't want the entire response cached, but only what you used it for. Also what you want to do when the response code is not 200 is not evident. For a create I just published I also use a cache, which is filled by a http request. https://github.com/gklijs/schema_registry_converter/blob/master/src/lib.rs but in this case I want to cache the Schema I get from the response, not the response itself.

1 Like

My plan is to port https://github.com/kornelski/http-cache-semantics to Rust

1 Like

I've written static_http_cache, but it's only really useful for static content. That is, it validates with the ETag header and If-Modified-Since, but it doesn't do anything with timed expiry or the more sophisticated cache-control headers.

4 Likes

I've implemented the HTTP RFC part, so you can use that to build the cache storage part:

4 Likes

Just wanted to pop in and say thanks for your work here on this. Published two caching middleware libraries that use it, really easy to implement.

Links if you’re interested, thanks again!

2 Likes