Build caching (2)
Last updated Sep 10, 2026 Improve Workers 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 Workers project will save relevant artifacts to cache. Every subsequent build will restore from cache unless configured otherwise.
About build cache
When enabled, build caching will automatically detect which package manager and framework the project is using from its package.json and cache data accordingly for the build.
The following shows which package managers and frameworks are supported for dependency and build output caching respectively.
Package managers
Workers build cache will cache the global cache directories of the following package managers:
| Package Manager | Directories cached |
|---|---|
| npm ↗︎ | .npm |
| yarn ↗︎ | .cache/yarn |
| pnpm ↗︎ | .pnpm-store, .local/share/pnpm/store |
| bun ↗︎ | .bun/install/cache |
If you configure pnpm to use a different store directory, Workers Builds does not cache it.
Frameworks
Some frameworks provide a cache directory that is typically populated by the framework with intermediate build outputs or dependencies during build time. Workers Builds 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 |
| Next.js | .next/cache |
| Nuxt | node_modules/.cache/nuxt |
| SvelteKit | node_modules/.cache/imagetools |
Note
Static assets and frameworks are now supported in Cloudflare Workers.
Limits
The following limits are imposed for build caching:
- Retention: Cache is purged 7 days after its last read date. Unread cache artifacts are purged 7 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:
- Navigate to Workers & Pages Overview ↗︎ on the Dashboard.
- Find your Workers project.
- Go to Settings > Build > Build cache.
- Select Enable to turn on build caching.
Clear build cache
The build cache can be cleared for a project when needed, such as when debugging build issues. To clear the build cache:
- Navigate to Workers & Pages Overview ↗︎ on the Dashboard.
- Find your Workers project.
- Go to Settings > Build > Build cache.
- Select Clear Cache to clear the build cache.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/ci-cd/builds/build-caching/#page","headline":"Build caching","description":"Improve build times by caching build outputs and dependencies","url":"https://developers.cloudflare.com/workers/ci-cd/builds/build-caching/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/ci-cd/builds/build-caching/og.png?v=d1835676ba6896c4","dateModified":"2026-09-10","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: Understand the build image used in Workers Builds. title: Build image image: https://developers.cloudflare.com/workers/ci-cd/builds/build-image/og.png?v=2dd0e4b778488d98
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.
Docs