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

推荐订阅源

Spread Privacy
Spread Privacy
K
Kaspersky official blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Forbes - Security
Forbes - Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Last Watchdog
The Last Watchdog
SecWiki News
SecWiki News
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts
WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
Security Latest
Security Latest
TaoSecurity Blog
TaoSecurity Blog
Cyberwarzone
Cyberwarzone
S
SegmentFault 最新的问题
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
T
The Blog of Author Tim Ferriss
H
Hacker News: Front Page
C
Cybersecurity and Infrastructure Security Agency CISA
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
AWS News Blog
AWS News Blog
AI
AI
G
GRAHAM CLULEY
IT之家
IT之家
P
Privacy & Cybersecurity Law Blog
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
D
Docker
Recent Announcements
Recent Announcements
O
OpenAI News
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
S
Security @ Cisco Blogs
T
Troy Hunt's Blog
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic

Flavio Copes

Workers Cache: a cache in front of your Cloudflare Worker 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 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)
How the Cloudflare Pages build cache works
Flavio Copes · 2026-07-08 · via Flavio Copes

By Flavio Copes

How the Cloudflare Pages build cache speeds up deploys, which directories it restores for each framework, and how to keep your own caches between builds.

~~~

Every time you push, Cloudflare Pages runs a fresh build from scratch. Fresh means slow: it reinstalls your dependencies and rebuilds everything, every time.

The build cache fixes part of this. It saves some directories after a build and restores them on the next one.

It’s off by default. You turn it on in the dashboard, in your Pages project’s build settings.

What it actually caches

The build cache doesn’t save your whole project. It saves two specific things.

First, your package manager’s cache, so installs are faster:

  • npm caches .npm
  • pnpm caches .pnpm-store
  • yarn caches .cache/yarn

Second, one cache directory per framework. Cloudflare detects your framework and restores its known cache folder:

  • Astro: node_modules/.astro
  • Next.js: .next/cache
  • Gatsby: .cache and public
  • Nuxt: node_modules/.cache/nuxt

That’s the important detail. It’s an allow-list. Cloudflare only restores those exact folders, and you can’t add your own.

The gotcha that caught me

I generate an Open Graph image for every post at build time. The tool caches each image so it doesn’t redraw the ones that didn’t change.

By default it cached them in node_modules/.astro-og-canvas. That folder isn’t on Cloudflare’s list, so it got thrown away after every build. Every deploy regenerated all 1800 images.

The fix

The fix is to cache inside a folder Cloudflare keeps. For Astro, that’s node_modules/.astro.

So I pointed the cache there:

getImageOptions: (path, page) => ({
  cacheDir: './node_modules/.astro/astro-og-canvas',
  title: page.title,
})

Now the cache rides along with Astro’s own cache. After the first deploy seeds it, only new and changed posts get regenerated.

My build went from redrawing everything to redrawing almost nothing. A cold build takes about 45 seconds. With the cache warm, about 12.

The takeaway

If a tool in your build writes a cache, check where it writes it. On Cloudflare Pages, put it inside your framework’s cache folder, or it won’t survive the next deploy.

~~~

Related posts about cloudflare: