Expand description
Response caching — an ADDITIVE layer in front of resolve that NEVER weakens
fail-closed. URNs are content-addressed → immutable → cacheable.
§What is safe to cache
- Only VERIFIED
Successbytes. AnIntegrityFailure/Unreachable/NotFound/ any error outcome is NEVER cached (a cachedUnreachablewould block recovery when the network returns; caching a failure is simply wrong). - Keyed by the content-addressed identity
storeId:root:resourceKey:saltwith the CONCRETE resolved root — never the raw request URN. A root-pinned URN is immutable; a rootless URN is cached under the root the resolve actually produced (from the node’sX-Dig-Root), so it can’t go stale when the store advances.
§Two tiers, two trust levels
- Memory (LRU, bounded): process-trusted — it only ever holds what THIS process already verified THIS run, so a memory hit may skip re-verification.
- Disk (optional, native): UNTRUSTED storage. It caches the verifiable
artifacts (ciphertext + inclusion proof + chunk lengths), NOT plaintext, so a
disk hit is RE-VERIFIED against the URN’s chain-anchored root before use (see
DiskArtifacts). A tampered on-disk file therefore FAILS verification →IntegrityFailure, and its bytes are never served. Filenames are the SHA-256 of the identity (content-addressed, no path-traversal from the URN).
Structs§
- Disk
Artifacts - The verifiable artifacts of an rpc-path fetch — enough to RE-VERIFY the bytes from scratch against the URN’s root. Persisted to the disk cache so a disk hit is re-verified (never trusted blindly).
- Disk
Cache - A content-addressed disk cache of
DiskArtifacts. UNTRUSTED: every read is re-verified by the caller against the URN’s root before use. - Memory
Cache - A bounded in-memory LRU of verified plaintext, keyed by
content_id. Bounded by BOTH an entry count and a total-byte budget (this ends up in a wallet — no unbounded growth). Process-trusted: a hit returns without re-verification.
Constants§
- DEFAULT_
MEMORY_ BYTES - See
DEFAULT_MEMORY_ENTRIES. - DEFAULT_
MEMORY_ ENTRIES - The default memory-cache bounds: 256 entries or 32 MiB, whichever binds first.
Functions§
- content_
id - The content-addressed cache identity:
storeId:root:resourceKey:salt.rootMUST be the CONCRETE resolved root (pinned root, or the node’sX-Dig-Root).