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.
Cargo.toml
toml
[dependencies]
reqwest-middleware-cache = "0.1.0"
With cargo add installed :
sh
cargo add reqwest-middleware-cache
```rust use reqwest::Client; use reqwestmiddleware::{ClientBuilder, Result}; use reqwestmiddleware_cache::{managers::CACacheManager, Cache, CacheMode};
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(()) } ```
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.This project is licensed under the Apache-2.0 License