feat: add cache() middleware for server-side response caching#3782
feat: add cache() middleware for server-side response caching#3782bartlomieju wants to merge 1 commit intomainfrom
Conversation
Adds a first-party middleware that caches responses using the Web Cache API. Routes opt in via standard Cache-Control headers — no new config surface needed. Supports stale-while-revalidate for ISR-like background revalidation. Closes #8
|
Nice work — the implementation is clean and follows the existing middleware conventions well. A few things that aren't covered here that might be worth considering as follow-ups: Pluggable cache backend — This uses the Web Cache API exclusively, which works great on Deno Deploy but ties caching to the runtime. A CDN cache coordination — For apps behind a CDN (Cloudflare, Fastly, etc.), it's common to need
None of these block the initial merge — the current scope is solid and the SWR via |
Summary
cache()middleware that uses the Web Cache API for server-side response cachingCache-Controlresponse headers — no new config surface or framework-specific DSL neededstale-while-revalidatefor ISR-like behavior (serve stale immediately, regenerate in background)private/no-store,Set-Cookie, non-200, and partial requestscacheName,methods, and customshouldCachefunctionstaticFiles(),cors(), etc.)Usage
Routes opt in:
Closes #8
Test plan