Crate http_cache

Source
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
CACacheManager
Implements CacheManager with cacache as the backend.
CacheOptions
Options struct provided by http-cache-semantics. Configuration options which control behavior of the cache. Use with CachePolicy::new_options().
HttpCache
Caches requests according to http spec.
HttpCacheOptions
Can be used to override the default CacheOptions and cache key. The cache key is a closure that takes http::request::Parts and returns a String.
HttpResponse
A basic generic type that represents an HTTP response

Enums§

CacheMode
Similar to make-fetch-happen cache options. Passed in when the HttpCache struct is being built.
HitOrMiss
Represents a basic cache status Used in the custom headers x-cache and x-cache-lookup
HttpVersion
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§

CacheManager
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.
CacheBust
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.
CacheKey
A closure that takes http::request::Parts and returns a String. By default, the cache key is a combination of the request method and uri with a colon in between.
CacheModeFn
A closure that takes http::request::Parts and returns a CacheMode
Result
A Result typedef to use with the BoxError type