Expand description
XDG disk cache for successful HTTP GET bodies between process invocations.
Cache key = SHA-256(url || NUL || parser_version || NUL || accept). Each entry stores body bytes plus metadata with body checksum; corrupt or expired entries are discarded and re-fetched.
Budget: optional max_bytes evicts oldest entries after each successful put.
ttl == 0 means entries never hit (always re-fetch).
Poisoned-entry guards: body reads are capped by [HARD_MAX_BODY_BYTES] (and the
cache soft budget); meta JSON reads are capped by MAX_CACHE_META_BYTES. Both
paths use fallible try_reserve_exact before filling buffers (never unbounded
fs::read / fs::read_to_string on attacker-controlled sizes).
Layout (SRP): [types] · [hex] · [meta] · [paths] · [disk].
Structs§
- Cache
Clear Result - Result of
cache clear. - Cache
Stats - Aggregate cache inventory for
cache stats/ doctor. - Disk
Cache - Disk cache rooted at an XDG (or override) directory.
Constants§
- CACHE_
PARSER_ VERSION - Bump when HTML/JSON parse semantics change so stale entries are ignored.
- DEFAULT_
CACHE_ TTL_ SECS - Default entry TTL (24 hours).
- DEFAULT_
MAX_ CACHE_ BYTES - Default on-disk budget (256 MiB).
0means unlimited. - MAX_
CACHE_ META_ BYTES - Hard ceiling for on-disk cache meta JSON (poisoned-entry guard).
Functions§
- resolve_
cache_ dir - Resolve cache root: explicit CLI override, then XDG cache home.
- resolve_
cache_ dir_ with_ source - Resolve cache root and report which layer won.