2 releases

0.1.1 Jan 7, 2022
0.1.0 Dec 5, 2021

#14 in #http-cache

Download history 75/week @ 2024-03-11 28/week @ 2024-03-18 47/week @ 2024-03-25 78/week @ 2024-04-01 28/week @ 2024-04-08 33/week @ 2024-04-15 33/week @ 2024-04-22 23/week @ 2024-04-29 48/week @ 2024-05-06 38/week @ 2024-05-13 28/week @ 2024-05-20 47/week @ 2024-05-27 35/week @ 2024-06-03 26/week @ 2024-06-10 36/week @ 2024-06-17 31/week @ 2024-06-24

134 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

~5–20MB
~311K SLoC