Expand description
Response caching (proxy-cache), ported from APISIX’s
apisix/plugins/proxy-cache.
Serving a cached response means looking up the cache before the upstream
call and storing the fresh response after it — two moments a single
featherbit node cannot span. The behavior is expressed as a pair of
nodes sharing one cache, linked by a required id:
- a lookup node placed before
upstream, which serves a cache hit straight to the client (short-circuiting the upstream call), and - a store node placed after
upstream, which caches a fresh response for later hits.
Both nodes derive the cache key identically from the same cache_key
template and the request, and share one namespace via id, so they always
agree. State lives in crate::traffic::CacheRegistry.
§Wiring
┌──────────────────┐ ┌──────────┐ ┌──────────────────┐
listener →│ proxy-cache │success →│ upstream │success →│ proxy-cache │→ client
│ (phase=lookup) │ │ │ │ (phase=store) │
└──────────────────┘ └──────────┘ └──────────────────┘
│ error (caches responses
▼ whose status is cacheable)
client.in
(cached response, HIT)On a hit, the lookup node writes the cached response onto the context, adds
featherbit-cache-status: HIT, and fails with PROXY_CACHE_HIT — its error
port goes to client.in, delivering the cached response without touching
the upstream. On a miss it passes through; the store node then caches the
upstream response and marks it featherbit-cache-status: MISS.
Structs§
- Proxy
Cache Plugin - One node of a
proxy-cachelookup/store pair.
Enums§
- Role 🔒
- Which half of the pair this node is.
Constants§
- CACHE_
STATUS_ 🔒HEADER - Header written by both nodes to report the cache outcome.
- HIDDEN_
HEADERS 🔒 - Response headers hidden from clients when
hide_cache_headersis set.
Functions§
- parse_
statuses 🔒 - Reads a
Vec<u16>of HTTP statuses from a JSON array, if present and valid.