A caching middleware for Surf that follows HTTP caching rules, thanks to http-cache-semantics. By default it uses cacache as the backend cache manager.
Cargo.toml
[dependencies]
surf-middleware-cache = "0.2.2"
With cargo add installed :
cargo add surf-middleware-cache
use surf_middleware_cache::{managers::CACacheManager, Cache, CacheMode};
#[async_std::main]
async fn main() -> surf::Result<()> {
let req = surf::get("https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching");
surf::client()
.with(Cache {
mode: CacheMode::Default,
cache_manager: CACacheManager::default(),
})
.send(req)
.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