Crates.io | surf-middleware-cache |
lib.rs | surf-middleware-cache |
version | 0.2.3 |
source | src |
created_at | 2021-11-27 19:02:17.073217 |
updated_at | 2022-01-08 16:54:45.013574 |
description | A caching middleware for Surf |
homepage | https://github.com/06chaynes/surf-middleware-cache |
repository | https://github.com/06chaynes/surf-middleware-cache |
max_upload_size | |
id | 488526 |
size | 90,199 |
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.
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