PRO

Cloudflare Worker Cache Tags

Workers HTTP Cache used the way it is meant to be used: cache: { enabled: true } puts a cache in front of the fetch handler so a hit never invokes the Worker, and the Worker's only job becomes emitting Cache-Control plus Cache-Tag and purging tags on write. Includes a derived tag vocabulary, tagged negative caching for 404s, stale-while-revalidate, ctx.cache.purge({ tags }) from a WorkerEntrypoint, the module-level cache import from cloudflare:workers for a queue consumer that has no ctx, pathPrefixes purge, and a per-export cache override so the admin entrypoint stays uncached.

Install
npx shadcn@latest add https://ui.aryank.space/r/cloudflare-worker-cache-tags.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
on write, purge
product page
unknown
home page
unknown
origin
unknown
await caches.default.purgeEverything() // one write, every key cold

One product's price changes and the only lever is purge-all, so the entire cache empties. Every request that was a 2ms hit is suddenly a miss, and the origin absorbs the whole site's traffic at once because one row changed.

Files

Dependencies
@cloudflare/[email protected]