2 releases

0.1.1 Jan 7, 2022
0.1.0 Dec 5, 2021

#19 in #reqwest-middleware

Download history 19/week @ 2023-11-18 42/week @ 2023-11-25 21/week @ 2023-12-02 18/week @ 2023-12-09 19/week @ 2023-12-16 16/week @ 2023-12-23 2/week @ 2023-12-30 15/week @ 2024-01-06 23/week @ 2024-01-13 16/week @ 2024-01-20 13/week @ 2024-01-27 13/week @ 2024-02-03 24/week @ 2024-02-10 45/week @ 2024-02-17 70/week @ 2024-02-24 41/week @ 2024-03-02

189 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–21MB
~328K SLoC