Post

Cloudflare just gave every Worker its own cache — not the zone's cache, the Worker's own. One line in wrangler config + the same Cache-Control headers you already know. No dashboard, no rules engine, no second product to configure. 🧵👇 #cloudflare #workers #cache #buildinpublic

1 repost6 likes

Why this matters: Workers used to sit in front of an origin. Now frameworks like Astro, Next.js, Remix & SvelteKit ship Cloudflare adapters where the Worker IS the origin — every request re-ran your code with nothing to cache. Workers Cache flips that.

Config is tiny. Add this to wrangler.jsonc: `{ "cache": { "enabled": true } }` Then just set Cache-Control on your Response like normal HTTP, and purge with `ctx.cache.purge({ tags: [...] })` That's the entire API surface.

`stale-while-revalidate` is what makes it feel instant. When a cache entry expires, Cloudflare serves the stale copy immediately while your Worker refreshes it in the background. No visitor ever waits on a cold render after the very first request.

Vary header support means one URL can have multiple cached variants — HTML vs JSON, WebP vs JPEG, per-locale pages — without losing caching entirely. It's standard HTTP content negotiation, not a Cloudflare-specific workaround.