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.
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.
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.
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.
Workers build cache will cache the global cache directories of the following package managers:
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 |
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.