HTTP client with cache?


#1

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.


#2

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


#3

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


#4

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.


#5

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


#6

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.