Expand description
A caching middleware that follows HTTP caching rules, thanks to
http-cache-semantics
.
By default, it uses cacache
as the backend cache manager.
§Features
The following features are available. By default manager-cacache
and cacache-async-std
are enabled.
manager-cacache
(default): enable cacache, a high-performance disk cache, backend manager.cacache-async-std
(default): enable async-std runtime support for cacache.cacache-tokio
(disabled): enable tokio runtime support for cacache.manager-moka
(disabled): enable moka, a high-performance in-memory cache, backend manager.with-http-types
(disabled): enable http-types type conversion support
Structs§
- BadHeader
- Error type for bad header values
- BadVersion
- Error type for unknown http versions
- CACache
Manager - Implements
CacheManager
withcacache
as the backend. - Cache
Options - Options struct provided by
http-cache-semantics
. Configuration options which control behavior of the cache. Use withCachePolicy::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
Enums§
- Cache
Mode - Similar to make-fetch-happen cache options.
Passed in when the
HttpCache
struct is being built. - HitOr
Miss - Represents a basic cache status
Used in the custom headers
x-cache
andx-cache-lookup
- Http
Version - Represents an HTTP version
Constants§
- XCACHE
x-cache
header: Value will be HIT if the response was served from cache, MISS if not- XCACHELOOKUP
x-cache-lookup
header: Value will be HIT if a response existed in cache, MISS if not
Traits§
- Cache
Manager - A trait providing methods for storing, reading, and removing cache records.
- Middleware
- Describes the functionality required for interfacing with HTTP client middleware
Type Aliases§
- BoxError
- Generic error type for the
HttpCache
middleware. - Cache
Bust - A closure that takes
http::request::Parts
,Option<CacheKey>
, the default cache key ([&str``]) and returns [
Vec`] of keys to bust the cache for. An empty vector means that no cache busting will be performed. - Cache
Key - A closure that takes
http::request::Parts
and returns aString
. By default, the cache key is a combination of the request method and uri with a colon in between. - Cache
Mode Fn - A closure that takes
http::request::Parts
and returns aCacheMode
- Result
- A
Result
typedef to use with theBoxError
type