Build caching
Improve Workers Builds build times by turning on build caching to restore dependencies and build output between builds. 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.
Configuration
Enable build caching
To enable build caching in the Cloudflare dashboard:
- Log in to the Cloudflare dashboard ↗ and select your account.
- In Account Home, select Workers & Pages.
- In Overview, select your Workers project.
- Go to Settings > Build > Build cache and select Enable.
Clear cache
The build cache can be cleared for a project when needed, such as when debugging build issues. To clear the build cache:
- Log in to the Cloudflare dashboard ↗ and select your account.
- In Account Home, select Workers & Pages.
- In Overview, select your Workers project.
- Go to Settings > Build > Build cache.
- Select Clear Cache to clear the build cache.
How build caching works
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:
Frameworks
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 |
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.