Crate surf_middleware_cache

Source
Expand description

A caching middleware for Surf that follows HTTP caching rules. By default it uses cacache as the backend cache manager.

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

Modules§

managers
Backend cache managers, cacache is the default.

Structs§

Cache
Caches requests according to http spec

Enums§

CacheMode
Similar to make-fetch-happen cache options. Passed in when the Cache struct is being built.

Traits§

CacheManager
A trait providing methods for storing, reading, and removing cache records.