Expand description
A memory cache implementing the logic specified in http://tools.ietf.org/html/rfc7234 and http://tools.ietf.org/html/rfc7232.
StructsΒ§
- Cache
Key - The key used to differentiate requests in the cache.
- Cached
Metadata π - Metadata about a loaded resource, such as is obtained from HTTP headers.
- Cached
Resource - A complete cached resource.
- Cached
Response π - Wrapper around a cached response, including information on re-validation needs
- Http
Cache - A simple memory cache.
Elements will be evicted based on the cache heuristic. We weight elements
by the number of entries per given url. We evict currently a whole url.
The cache makes extensive use of
Arc::unwrap_or_clone orandArc::into_innerto modify the cached entries. This is ok becauseCachedResourceare cheap to clone
EnumsΒ§
- Cached
Resources OrGuard - Returns an writeable entry into the cache or a guard for insertint an entry The guard will block other queries to the cache entry in both cases.
- Validation
Status - Whether a cached response is fresh or requires validation before or after use.
FunctionsΒ§
- calculate_
response_ πage - Calculating Age https://tools.ietf.org/html/rfc7234#section-4.2.3
- construct_
response π - Constructing Responses from Caches. https://tools.ietf.org/html/rfc7234#section-4
- create_
cached_ πresponse - Create a CachedResponse from a request and a CachedResource.
- create_
resource_ πwith_ bytes_ from_ resource - Create a new resource, based on the bytes requested, and an existing resource, with a status-code of 206.
- get_
expiry_ πadjustment_ from_ request_ headers - Request Cache-Control Directives https://tools.ietf.org/html/rfc7234#section-5.2.1
- get_
response_ πexpiry - Determine the expiry date from relevant headers, or uses a heuristic if none are present.
- get_
stale_ πwhile_ revalidate - The
headerscrateβsCacheControldoes not understandstale-while-revalidatedirective, so we need to parse the rawCache-Controlheader values. https://datatracker.ietf.org/doc/html/rfc5861#section-3 - handle_
range_ πrequest - Support for range requests https://tools.ietf.org/html/rfc7233.
- invalidate_
cached_ πresources - is_
cacheable_ πby_ default - Determine if a response is cacheable by default https://tools.ietf.org/html/rfc7231#section-6.1
- refresh
- Freshening Stored Responses upon Validation. https://tools.ietf.org/html/rfc7234#section-4.3.4
- request_
demands_ πrevalidation - Determine whether the request itself demands revalidation. https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.1
- resolve_
location_ πurl - response_
is_ πcacheable - Determine if a given response is cacheable. Based on https://tools.ietf.org/html/rfc7234#section-3
Type AliasesΒ§
- Cache
Entry π - OurLifecycle π
- Quick
Cache π - Quick
Cache πPlaceeholder Guard