Skip to main content

Module http_cache

Module http_cache 

Source
Expand description

Pure pieces of the client’s HTTP cache: key derivation, Cache-Control and Retry-After parsing, the storage decision, and the on-disk entry format.

Experimental until 0.9. This module does no I/O and reads no clock; callers pass times as Unix seconds. libtea-client does the file work (docs/cache.md).

A cache entry is not a trusted statement. The entry format carries a length and a SHA-256 of the body so that truncation and accidental corruption are detected. Anyone who can write the cache directory can write a consistent entry, so the hash is not authentication. Artifact bytes are therefore checked against the declared checksums every time they are used, and the directory is created private (docs/cache.md).

Structs§

CacheControl
The directives of Cache-Control this client acts on.
CacheEntryMeta
Metadata of one stored response.
EntryBuilder
Builds an entry while the body is still arriving.

Enums§

EntryError
Why an entry was refused.
NotStored
Why a response was not stored.

Constants§

CACHE_FORMAT_VERSION
Entry layout version written and read by this crate.
MAX_META_BYTES
Largest metadata block accepted.
STORED_HEADERS
Response headers an entry keeps, and nothing else.

Functions§

cache_key
The cache key of a request: lowercase hex SHA-256 over the method, the normalized URL, and a digest of the origin and the API key id (never the secret). Requests from different keys, or to different origins, never share an entry.
decode_entry
Decode and check an entry.
encode_entry
Encode a whole entry in memory.
is_cache_key
Whether key looks like a key produced by cache_key.
is_storable_header
Whether a header may be written to an entry: allow-listed, and a value of visible ASCII (and tab) no longer than 8 KiB.
parse_retry_after
Seconds to wait according to a Retry-After value.
storage_decision
Decide whether a response may be stored.