Crate http_cache_surf
source ·Expand description
The surf middleware implementation for http-cache.
use http_cache_surf::{Cache, CacheMode, CACacheManager, HttpCache, HttpCacheOptions};
#[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(HttpCache {
mode: CacheMode::Default,
manager: CACacheManager::default(),
options: HttpCacheOptions::default(),
}))
.send(req)
.await?;
Ok(())
}Structs§
- CACacheManager
manager-cacacheImplementsCacheManagerwithcacacheas the backend. - Wrapper for
HttpCache - Configuration options which control behavior of the cache. Use with
CachePolicy::new_options(). - Caches requests according to http spec.
- Can be used to override the default
CacheOptionsand cache key. The cache key is a closure that takeshttp::request::Partsand returns aString. - A basic generic type that represents an HTTP response
- MokaCache
manager-mokaA thread-safe, futures-aware concurrent in-memory cache. - MokaCacheBuilder
manager-mokaBuilds aCachewith various configuration knobs. - MokaManager
manager-mokaImplementsCacheManagerwithmokaas the backend. - Component parts of an HTTP
Request
Enums§
- Similar to make-fetch-happen cache options. Passed in when the
HttpCachestruct is being built.
Traits§
- A trait providing methods for storing, reading, and removing cache records.