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

#68 in HTTP client

Download history 3402/week @ 2024-01-29 2494/week @ 2024-02-05 3609/week @ 2024-02-12 4842/week @ 2024-02-19 5943/week @ 2024-02-26 7063/week @ 2024-03-04 6446/week @ 2024-03-11 6846/week @ 2024-03-18 7387/week @ 2024-03-25 6691/week @ 2024-04-01 7494/week @ 2024-04-08 8329/week @ 2024-04-15 5946/week @ 2024-04-22 5780/week @ 2024-04-29 6215/week @ 2024-05-06 5491/week @ 2024-05-13

24,219 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–38MB
~622K SLoC