5 releases

0.2.3 Jan 8, 2022
0.2.2 Dec 5, 2021
0.2.1 Nov 30, 2021
0.2.0 Nov 28, 2021
0.1.0 Nov 27, 2021

#13 in #http-cache

Download history 10/week @ 2024-03-09 7/week @ 2024-03-30 127/week @ 2024-06-08 7/week @ 2024-06-15

134 downloads per month

Apache-2.0

26KB
440 lines

surf-middleware-cache

Rust crates.io Docs.rs

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.

Install

With cargo add installed :

cargo add surf-middleware-cache

Example

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(())
}

Features

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.

Documentation

License

This project is licensed under the Apache-2.0 License

Dependencies

~8–22MB
~314K SLoC