惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
The GitHub Blog
The GitHub Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
Y
Y Combinator Blog
Cloudbric
Cloudbric
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cybersecurity and Infrastructure Security Agency CISA
TaoSecurity Blog
TaoSecurity Blog
Security Latest
Security Latest
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Hacker News: Front Page
C
Cisco Blogs
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V
Vulnerabilities – Threatpost
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
About on SuperTechFans
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
Schneier on Security
Schneier on Security
T
Tenable Blog
N
News and Events Feed by Topic
W
WeLiveSecurity
有赞技术团队
有赞技术团队
AI
AI
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
Latest news
Latest news
T
The Blog of Author Tim Ferriss
S
Security Affairs
Know Your Adversary
Know Your Adversary
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
Google DeepMind News
Google DeepMind News
The Cloudflare Blog

Flavio Copes

Cloudflare Drop: drag a folder, get a live site Temporary Cloudflare accounts: agents can now deploy without signing up Moondream 3.1 on Workers AI: fast vision at the edge inferencecost.dev: what will AI inference cost you at 10k users? Sitebase: all the features your website needs, in one place StackPlan: figure out where to deploy your app, and what it How the Cloudflare Pages build cache works The Summer of Code How I generate an Open Graph image for every post New: 90 free tools for developers How I added search to my static site with Pagefind How to rebuild a Cloudflare site on a schedule Cloudflare Email Workers: run code when an email arrives Cloudflare Turnstile: stop bots without annoying CAPTCHAs Cloudflare Workers: secrets and environments Cloudflare Workers observability: logs and traces Cloudflare Analytics Engine: store and query metrics The AI Workshop (July 2026 cohort) Cloudflare Cron Triggers: run a Worker on a schedule Cloudflare Durable Objects: state that lives in one place Cloudflare Queues: run work in the background Cloudflare R2: object storage without egress fees Cloudflare KV: a key-value store for your Workers Cloudflare D1: a SQL database for your Workers Serving a website with Cloudflare Workers static assets Wrangler: the Cloudflare Workers command line tool Executor: one gateway to connect your AI agent to every tool Cloudflare Workers: your first serverless function Vercel eve: an open framework for building AI agents Flue: the open framework for building AI agents Val Town: write and deploy code in seconds A hands-on guide to The Agency, a collection of AI agents The AI Workshop (June 2026 cohort) The AI Workshop (May 2026 cohort) The AI Workshop (Apr 2026 cohort)
Workers Cache: a cache in front of your Cloudflare Worker
Flavio Copes · 2026-07-09 · via Flavio Copes

By Flavio Copes

Cloudflare launched Workers Cache, a tiered cache that sits in front of your Worker. How to enable it, set Cache-Control headers, and purge by tag.

~~~

Cloudflare just launched Workers Cache, and it fixes something that always bugged me about running apps on Workers.

Here’s the problem. When your Worker is your app, there’s nothing in front of it. Every request runs your code. Even when the response is identical to the one you returned a second ago, you still pay the render time and the CPU cost.

Workers Cache puts Cloudflare’s cache in front of the Worker. On a cache hit, your code doesn’t run at all. Cloudflare returns the cached response directly, and you pay zero CPU time for it.

Enabling it

One line in your wrangler.jsonc:

{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2026-05-01",
  "cache": { "enabled": true }
}

That’s it. No zone settings, no cache rules, no separate product to configure.

Once the cache is enabled, you configure it the way HTTP always intended: with Cache-Control headers on your responses.

export default {
  async fetch(request) {
    const html = await renderPage(request)

    return new Response(html, {
      headers: {
        'Content-Type': 'text/html; charset=utf-8',
        'Cache-Control': 'public, max-age=300, stale-while-revalidate=3600',
      },
    })
  },
}

This says: treat the response as fresh for 5 minutes, and for up to an hour after that, keep serving the stale copy while refreshing it in the background.

The stale-while-revalidate part is what makes it feel instant. Without it, the first request after the cache expires waits for a full render. With it, that user gets the stale page immediately, and the Worker refreshes the cache in the background. Nobody waits.

I wrote more about how these headers work in HTTP caching.

Purging when content changes

You can tag responses with a Cache-Tag header:

return new Response(body, {
  headers: {
    'Cache-Control': 'public, max-age=300',
    'Cache-Tag': 'products,product:123',
  },
})

Then when the data changes, your Worker purges its own cache:

await ctx.cache.purge({ tags: ['product:123'] })

The purge is scoped to your Worker. No risk of accidentally wiping cached content for the rest of your zone.

It’s tiered by default

Workers Cache is a two-layer cache. There’s a lower tier in the data center closest to the user, and an upper tier that aggregates fills across the whole network.

The nice consequence: the first request from anywhere in the world populates the upper tier. After that, requests from any location can be served from cache, even if their local data center has never seen that URL before.

You don’t configure any of this. Every Worker with caching enabled gets tiering for free.

Caching between Workers

This is the part I find most interesting. The cache doesn’t just sit in front of the public URL. It sits in front of every Worker entrypoint, including calls between Workers over service bindings, and even calls between entrypoints in the same Worker.

You decide per entrypoint which ones cache:

{
  "cache": { "enabled": true },
  "exports": {
    "default": { "type": "worker", "cache": { "enabled": false } },
    "CachedBackend": { "type": "worker", "cache": { "enabled": true } }
  }
}

The typical pattern: an outer entrypoint that authenticates on every request (never cached), calling an inner entrypoint that does the expensive work (cached). You get auth on every request and a cache in front of the slow part, in one Worker.

For per-user data, the caller’s ctx.props becomes part of the cache key. Pass a userId in the props and each user gets their own cache entries. One user can never see another user’s cached response.

Billing

Cache hits don’t bill CPU time. They count as a normal request at the standard rate, but your Worker doesn’t run.

One thing to watch: with caching enabled, requests that used to be free, like static asset requests and worker-to-worker calls, are billed at the standard request rate, because each one now consults the cache.

Astro support is already there

If you deploy Astro on Cloudflare, the adapter wires this up for you:

// astro.config.mjs
import { defineConfig } from 'astro/config'
import cloudflare from '@astrojs/cloudflare'
import { cacheCloudflare } from '@astrojs/cloudflare/cache'

export default defineConfig({
  adapter: cloudflare(),
  output: 'server',
  experimental: {
    cache: { provider: cacheCloudflare() },
    routeRules: {
      '/products/*': { maxAge: 300, swr: 3600, tags: ['products'] },
    },
  },
})

Server-rendered pages get the render-once-then-cache flow automatically. Integrations for other frameworks are on the way.

Workers Cache is available today on every plan, including the free one. If you run anything server-rendered on Workers, add "cache": { "enabled": true } and set some headers. It’s the cheapest performance win you’ll get this year.

~~~

Related posts about cloudflare: