2 releases

0.1.1 Jan 7, 2022
0.1.0 Dec 5, 2021

#27 in #reqwest-middleware

Download history 37/week @ 2025-09-11 46/week @ 2025-09-18 47/week @ 2025-09-25 30/week @ 2025-10-02 50/week @ 2025-10-09 53/week @ 2025-10-16 28/week @ 2025-10-23 11/week @ 2025-10-30 20/week @ 2025-11-06 49/week @ 2025-11-13 17/week @ 2025-11-20 23/week @ 2025-11-27 18/week @ 2025-12-04 11/week @ 2025-12-11 15/week @ 2025-12-18 5/week @ 2025-12-25

61 downloads per month
Used in 3 crates (via maplibre)

Apache-2.0

28KB
476 lines

reqwest-middleware-cache

Rust crates.io Docs.rs

A caching middleware for reqwest 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.

Install

With cargo add installed :

cargo add reqwest-middleware-cache

Example

use reqwest::Client;
use reqwest_middleware::{ClientBuilder, Result};
use reqwest_middleware_cache::{managers::CACacheManager, Cache, CacheMode};

#[tokio::main]
async fn main() -> Result<()> {
    let client = ClientBuilder::new(Client::new())
        .with(Cache {
            mode: CacheMode::Default,
            cache_manager: CACacheManager::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): use cacache, a high-performance disk cache, for the manager backend.

Documentation

License

This project is licensed under the Apache-2.0 License

Dependencies

~6–25MB
~341K SLoC