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§
- CACache
Manager manager-cacache
- Implements
CacheManager
withcacache
as the backend. - Cache
- Wrapper for
HttpCache
- Cache
Options - Configuration options which control behavior of the cache. Use with
CachePolicy::new_options()
. - Http
Cache - Caches requests according to http spec.
- Http
Cache Options - Can be used to override the default
CacheOptions
and cache key. The cache key is a closure that takeshttp::request::Parts
and returns aString
. - Http
Response - A basic generic type that represents an HTTP response
- Moka
Cache manager-moka
- A thread-safe, futures-aware concurrent in-memory cache.
- Moka
Cache Builder manager-moka
- Builds a
Cache
with various configuration knobs. - Moka
Manager manager-moka
- Implements
CacheManager
withmoka
as the backend. - Parts
- Component parts of an HTTP
Request
Enums§
- Cache
Mode - Similar to make-fetch-happen cache options.
Passed in when the
HttpCache
struct is being built.
Traits§
- Cache
Manager - A trait providing methods for storing, reading, and removing cache records.