29 releases (13 breaking)

0.14.0 Apr 11, 2024
0.13.0 Jan 15, 2024
0.12.0 Nov 1, 2023
0.11.1 Jul 29, 2023
0.4.1 Mar 29, 2022

#64 in HTTP client

Download history 3518/week @ 2023-12-24 3975/week @ 2023-12-31 3065/week @ 2024-01-07 3997/week @ 2024-01-14 3833/week @ 2024-01-21 3348/week @ 2024-01-28 2553/week @ 2024-02-04 3316/week @ 2024-02-11 5072/week @ 2024-02-18 5282/week @ 2024-02-25 7358/week @ 2024-03-03 6750/week @ 2024-03-10 6229/week @ 2024-03-17 8017/week @ 2024-03-24 6390/week @ 2024-03-31 5106/week @ 2024-04-07

26,351 downloads per month
Used in 29 crates (19 directly)

MIT/Apache

76KB
1.5K SLoC

http-cache-reqwest

CI Crates.io Docs.rs Codecov Crates.io

the http-cache logo

A caching middleware that follows HTTP caching rules, thanks to http-cache-semantics. By default, it uses cacache as the backend cache manager. Uses reqwest-middleware for middleware support.

Minimum Supported Rust Version (MSRV)

1.67.1

Install

With cargo add installed :

cargo add http-cache-reqwest

Example

use reqwest::Client;
use reqwest_middleware::{ClientBuilder, Result};
use http_cache_reqwest::{Cache, CacheMode, CACacheManager, HttpCache, HttpCacheOptions};

#[tokio::main]
async fn main() -> Result<()> {
    let client = ClientBuilder::new(Client::new())
        .with(Cache(HttpCache {
          mode: CacheMode::Default,
          manager: CACacheManager::default(),
          options: HttpCacheOptions::default(),
        }))
        .build();
    client
        .get("https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching")
        .send()
        .await?;
    Ok(())
}

Features

The following features are available. By default manager-cacache is enabled.

  • manager-cacache (default): enable cacache, a high-performance disk cache, backend manager.
  • manager-moka (disabled): enable moka, a high-performance in-memory cache, backend manager.

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~5–41MB
~635K SLoC