01 // What it’s for
Why reach for Tiered Cache
Use @durability/transforms Tiered Cache to keep hot Durable Object reads fast, cheap, and resilient to traffic spikes or origin blips. Declare per-method TTLs once in a cachePlan, then compose only the tiers each caller needs via stub.with(...).
02 // How it works
Inside your Durable Object
- 013 composable hydraulic tiers:
memoryTieranswers in 0ms from isolate RAM (LRU);durableTierpersists inside the calling DO's storage to survive isolate eviction;workerCacheTier+serveCachedshare hits across an entire Cloudflare PoP. - 02Singleflight stampede protection: Concurrent cold misses collapse into one upstream origin call whose result backfills every tier on the return path.
- 03Stale-While-Revalidate & Stale-If-Error: Within
staleMs, callers receive an instant cached reply while one background probe refreshes Origin; on an Origin 503,staleIfErrorMsshields callers safely. - 04Configurable PoP fallback: When a Workers Cache hop times out or errors,
fallback: 'rpc'(default) bypasses directly to the origin stub—or set'throw'to surfaceCachedCallError.
Tiers
Memory → DO Storage → PoP
Protection
Singleflight + SWR + 503 Shield
Import
@durability/transforms