DEVOURED
Your Worker can now have its own cache in front of it
Cloudflare Workers now include a native, tiered caching layer that allows developers to serve cached responses without invoking code or incurring CPU costs.
What: Cloudflare introduced Workers Cache, a tiered caching system enabled via Wrangler config. It supports standard Cache-Control headers, stale-while-revalidate for background refreshes, and Vary for content negotiation. Cache keys are isolated per-Worker and support multi-tenant safety using ctx.props.
Why it matters: This transitions Workers from being strictly an origin-adjacent execution layer to a self-contained origin that can leverage edge caching, fundamentally improving the economics of server-side rendered applications.
Takeaway: Add "cache": { "enabled": true } to your wrangler.jsonc to stop re-rendering responses that are already cacheable.
Deep dive
- Tiered caching eliminates the choice between static generation and expensive on-demand rendering.
- Cache exists at the Worker level, not the zone level, allowing for granular, programmatic control.
- Stale-while-revalidate allows background cache updates, ensuring users never wait for a cold render.
- Vary support enables serving different content (JSON vs HTML) from the same URL cache.
- Service bindings and entrypoint calls now optionally pass through the cache for internal memoization.
- Billing is strictly by request count, as hits incur zero CPU time.
Decoder
- Vary: An HTTP header that tells caches that the response depends on specific request headers, preventing the cache from serving the wrong version of content to different clients.
- Service bindings: A way for one Worker to directly call another, allowing for modular architecture between decoupled services.
Original article
Full article content is not available for inline reading.
Explore all 56 articles in today's digest
Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi