surf-middleware-cache

Crates.iosurf-middleware-cache
lib.rssurf-middleware-cache
version0.2.3
sourcesrc
created_at2021-11-27 19:02:17.073217
updated_at2022-01-08 16:54:45.013574
descriptionA caching middleware for Surf
homepagehttps://github.com/06chaynes/surf-middleware-cache
repositoryhttps://github.com/06chaynes/surf-middleware-cache
max_upload_size
id488526
size90,199
Christian Haynes (06chaynes)

documentation

README

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

Commit count: 64

cargo fmt