Crates.io | reqwest-middleware-cache |
lib.rs | reqwest-middleware-cache |
version | 0.1.1 |
source | src |
created_at | 2021-12-05 16:37:04.6556 |
updated_at | 2022-01-07 00:21:39.768143 |
description | A caching middleware for reqwest |
homepage | https://github.com/06chaynes/reqwest-middleware-cache |
repository | https://github.com/06chaynes/reqwest-middleware-cache |
max_upload_size | |
id | 492758 |
size | 84,909 |
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.
With cargo add installed :
cargo add reqwest-middleware-cache
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(())
}
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