reqwest-middleware-cache

Crates.ioreqwest-middleware-cache
lib.rsreqwest-middleware-cache
version0.1.1
sourcesrc
created_at2021-12-05 16:37:04.6556
updated_at2022-01-07 00:21:39.768143
descriptionA caching middleware for reqwest
homepagehttps://github.com/06chaynes/reqwest-middleware-cache
repositoryhttps://github.com/06chaynes/reqwest-middleware-cache
max_upload_size
id492758
size84,909
Christian Haynes (06chaynes)

documentation

README

reqwest-middleware-cache

Rust crates.io Docs.rs

A caching middleware for reqwest that follows HTTP caching rules, thanks to http-cache-semantics. By default it uses cacache as the backend cache manager. Uses reqwest-middleware for middleware support.

Install

With cargo add installed :

cargo add reqwest-middleware-cache

Example

use reqwest::Client;
use reqwest_middleware::{ClientBuilder, Result};
use reqwest_middleware_cache::{managers::CACacheManager, Cache, CacheMode};

#[tokio::main]
async fn main() -> Result<()> {
    let client = ClientBuilder::new(Client::new())
        .with(Cache {
            mode: CacheMode::Default,
            cache_manager: CACacheManager::default(),
        })
        .build();
    client
        .get("https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching")
        .send()
        .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: 20

cargo fmt