Ai Engineering 3 min read

How to Cut CPU Costs with Cloudflare Workers Cache

You will learn how to configure Cloudflare Workers Cache to serve responses directly from entrypoints, handle invalidations, and partition cache keys.

Cloudflare’s new Workers Cache allows developers to serve cached HTTP responses directly from a Worker entrypoint without executing the underlying code. Released on July 6, 2026, this regionally tiered system replaces traditional zone-level CDN rules with a cache owned entirely by the Worker. Because cache hits skip the compute layer, this architecture significantly reduces latency and CPU billing for edge-heavy applications.

Workers Cache follows the Worker regardless of where it is invoked, operating seamlessly across workers.dev, custom domains, or service bindings. Here is how to configure it, manage cache lifecycles, and handle multi-tenant isolation.

Installation and Setup

Workers Cache requires Wrangler version 4.69.0 or higher. You enable the feature by adding a single configuration block to your wrangler.toml or wrangler.jsonc file.

toml name = “my-worker” main = “src/index.ts” compatibility_date = “2026-07-07”

[cache] enabled = true

Once enabled, the cache infrastructure automatically deploys a two-tier architecture. The lower tier caches data in the data center closest to the user, while the upper tier aggregates cache fills across regional data centers to maximize global hit rates.

Caching Logic and Headers

The cache behavior is controlled via standard HTTP RFC 9111 headers. Your Worker code dictates caching rules by returning specific headers in the HTTP response.

You control the cache duration and revalidation strategies using the Cache-Control header. Standard directives like max-age and stale-while-revalidate dictate how the upper and lower tiers hold the data. Content negotiation relies on the Vary header, allowing you to serve different cached responses based on incoming request properties.

Purging and Invalidation

Cloudflare supports two methods for invalidating cached responses.

For bulk operations, you can attach Cache-Tag headers to your responses. This allows you to group related assets and purge them simultaneously.

For granular, programmatic control, Workers Cache introduces a new invalidation API. A Worker can invalidate its own cache by calling ctx.cache.purge(), targeting specific tags or path prefixes. This is particularly useful when you need deterministic state updates after database mutations.

Multi-Tenant Safety and Composable Entrypoints

By default, cache keys are automatically scoped to the Worker version. This prevents unintentional data pollution across deployments.

For multi-tenant applications, you can further partition cache keys using ctx.props. This ensures strict data isolation between tenants, which is a critical requirement when you deploy Cloudflare Workers via temporary accounts for different enterprise clients.

The feature also enables composable entrypoints. A “gateway” Worker can handle authentication and then fetch data from an internal “backend” entrypoint using ctx.exports. If the backend entrypoint response is cached, the gateway fulfills the request without triggering the heavy data operations. This pattern is highly efficient when you build real-time voice agents with Cloudflare Agents SDK, allowing you to cache static context while dynamic logic executes at the gateway.

Limits and Technical Specifications

Workers Cache is generally available for all Cloudflare customers across Free, Paid, and Enterprise plans. There is no additional cost for the cache itself; you pay the standard request rates and save on CPU time for every cache hit.

SpecificationValue
Minimum Wrangler Version4.69.0
Max Response Body Size512 MB
Protocol StandardHTTP RFC 9111
Key ScopeWorker version (default)
AvailabilityGeneral Availability (GA)

Framework integration is actively expanding. Astro natively supports Workers Cache out of the box, with implementations for other major frameworks currently in progress.

Update your local Wrangler installation to version 4.69.0 and add the [cache] block to your active development environments to begin profiling CPU time savings.

Get Insanely Good at AI

Get Insanely Good at AI

The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.

Keep Reading