Build caching

Last updated May 27, 2026 Improve Pages build times by caching dependencies and build output between builds with a project-wide shared cache.

The first build to occur after enabling build caching on your Pages project will save to cache. Every subsequent build will restore from cache unless configured otherwise.

About build cache

When enabled, the build cache will automatically detect and cache data from each build. Refer to Frameworks to review what directories are automatically saved and restored from the build cache.

Requirements

Build caching requires the V2 build system or later. To update from V1, refer to the V2 build system migration instructions.

Package managers

Pages will cache the global cache directories of the following package managers:

Package Manager Directories cached
npm ↗︎ .npm
yarn ↗︎ .cache/yarn
pnpm ↗︎ .pnpm-store
bun ↗︎ .bun/install/cache

Frameworks

Some frameworks provide a cache directory that is typically populated by the framework with intermediate build outputs or dependencies during build time. Pages will automatically detect the framework you are using and cache this directory for reuse in subsequent builds.

The following frameworks support build output caching:

Framework Directories cached
Astro node_modules/.astro
Docusaurus node_modules/.cache, .docusaurus, build
Eleventy .cache
Gatsby .cache, public
Hugo .cache
Next.js .next/cache
Nuxt node_modules/.cache/nuxt
SvelteKit node_modules/.cache/imagetools

Hugo build caching

Hugo does not use .cache by default. To use build caching with Hugo, set --cacheDir=$PWD/.cache in your build command. For example:

hugo --minify --cacheDir=$PWD/.cache

Pages detects Hugo projects via the presence of a hugo.toml, hugo.yaml, hugo.yml, or hugo.json config file.

Limits

The following limits are imposed for build caching:

  • Retention: Cache is purged seven days after its last read date. Unread cache artifacts are purged seven days after creation.
  • Storage: Every project is allocated 10 GB. If the project cache exceeds this limit, the project will automatically start deleting artifacts that were read least recently.

Enable build cache

To enable build caching :

  1. Go to the Workers & Pages in the Cloudflare dashboard. Go to Workers & Pages ↗
  2. Find your Pages project.
  3. Go to Settings > Build > Build cache.
  4. Select Enable to turn on build caching.

Clear build cache

The build cache can be cleared for a project if needed, such as when debugging build issues. To clear the build cache:

  1. Go to the Workers & Pages in the Cloudflare dashboard. Go to Workers & Pages ↗
  2. Find your Pages project.
  3. Go to Settings > Build > Build cache.
  4. Select Clear Cache to clear the build cache.

Was this helpful?

YesNo

On this page

Build caching - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/pages/configuration/build-caching/#page","headline":"Build caching","description":"Speed up Cloudflare Pages builds by caching dependencies and build output between deployments.","url":"https://developers.cloudflare.com/pages/configuration/build-caching/","inLanguage":"en","image":"https://developers.cloudflare.com/pages/configuration/build-caching/og.png?v=10aa4620cc739f5b","dateModified":"2026-05-27","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Set build commands, output directories, and framework presets for Cloudflare Pages projects. title: Build configuration image: https://developers.cloudflare.com/pages/configuration/build-configuration/og.png?v=3b81c7eb16f14ab8


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/pages/llms.txt
Use this file to discover all available pages before exploring further.