CWorkers Cache recipe

SSR on Cloudflare Workers

A compact zfb recipe for response-header driven caching.

The cached routes do a small amount of request-time work, stamp the render time, and let Workers Cache decide reuse from HTTP headers.

Routes

Cached page/products
Header variant/catalog
Purge endpointPOST /api/purge

Cache controls

/products returns a cacheable HTML response with a products tag. /catalog varies by X-Catalog-Market and uses compatible tags so the same purge clears every variant.

Cache-Control: public, max-age=60, stale-while-revalidate=600

Purge

Set PURGE_TOKEN as a Worker secret, then call POST /api/purge with X-Purge-Token. The route uses ctx.cache.purge() with the products tag.