Crates.io | http-cache-ureq |
lib.rs | http-cache-ureq |
version | 1.0.0-alpha.1 |
created_at | 2025-08-25 03:15:31.297945+00 |
updated_at | 2025-08-25 03:15:31.297945+00 |
description | http-cache middleware implementation for ureq |
homepage | https://http-cache.rs |
repository | https://github.com/06chaynes/http-cache |
max_upload_size | |
id | 1809029 |
size | 159,329 |
A caching middleware that follows HTTP caching rules, thanks to http-cache-semantics. By default, it uses cacache as the backend cache manager. Provides a simple caching wrapper around ureq.
1.82.0
With cargo add installed :
cargo add http-cache-ureq
use http_cache_ureq::{CACacheManager, CachedAgent};
#[smol_macros::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let client = CachedAgent::builder()
.cache_manager(CACacheManager::default())
.build()?;
let response = client
.get("https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching")
.call()
.await?;
println!("Status: {}", response.status());
Ok(())
}
The CachedAgent
wraps ureq's functionality while providing transparent HTTP caching:
use http_cache_ureq::{CACacheManager, CachedAgent};
// Create a cached agent with default settings
let client = CachedAgent::builder()
.cache_manager(CACacheManager::default())
.build()?;
// Use it just like a regular ureq agent
let response = client.get("https://httpbin.org/json").call().await?;
The following features are available. By default manager-cacache
is enabled.
manager-cacache
(default): enable cacache, a high-performance disk cache, backend manager.manager-moka
(disabled): enable moka, a high-performance in-memory cache, backend manager.json
(disabled): enable JSON support via ureq's json feature.rate-limiting
(disabled): enable rate limiting functionality.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.