#cache #reqwest #middleware

reqwest-middleware-cache

A caching middleware for reqwest

2 releases

0.1.1 Jan 7, 2022
0.1.0 Dec 5, 2021

#16 in #reqwest

Download history 8/week @ 2022-01-23 9/week @ 2022-01-30 2/week @ 2022-02-06 2/week @ 2022-02-13 11/week @ 2022-02-20 7/week @ 2022-02-27 12/week @ 2022-03-06 58/week @ 2022-03-13 10/week @ 2022-03-20 31/week @ 2022-03-27 38/week @ 2022-04-03 5/week @ 2022-04-10 236/week @ 2022-04-17 154/week @ 2022-04-24 129/week @ 2022-05-01 159/week @ 2022-05-08

678 downloads per month
Used in 2 crates (via maplibre)

Apache-2.0

26KB
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

~7–16MB
~313K SLoC