Astro Info
Astro v7.0.9
Vite v8.1.4
Node v22.23.1
System Linux (x64)
Package Manager pnpm
Output server
Adapter @astrojs/cloudflare (v14.1.3)
Integrations none
Describe the Bug
When a Cloudflare cache provider is configured (cache: { provider: cacheCloudflare() }), the adapter force-enables the Workers Cache in the emitted config even when the project's wrangler.jsonc explicitly sets "cache": { "enabled": false }. The built dist/server/wrangler.json comes out with "cache": { "enabled": true }, so the opt-out is silently rewritten.
The check at packages/integrations/cloudflare/src/wrangler.ts#L73 is
cache: needsWorkerCache && !config.cache?.enabled ? { enabled: true } : undefined,
and !config.cache?.enabled treats "unset" and "explicitly false" the same.
For context on why someone would set enabled: false while still using the provider: Workers Cache supports per-entrypoint enablement, e.g. "exports": { "Render": { "type": "worker", "cache": { "enabled": true } } } with the default export left uncached. That shape is useful for an uncached gateway that derives cache-key dimensions (host, region) into ctx.props and loops back into a cached named entrypoint via ctx.exports, which seems to be the documented way to add key dimensions the platform does not provide. The exports block passes through the customizer untouched; only the top-level enabled: false gets overridden. The workaround for now is post-processing dist/server/wrangler.json between build and deploy.
What's the expected result?
An explicit "cache": { "enabled": false } in the user's wrangler config survives the build. Checking for config.cache?.enabled === undefined rather than falsiness would keep the current auto-enable default for configs that do not mention cache at all, while respecting an explicit opt-out.
Link to Minimal Reproducible Example
https://github.com/skezo/astro-cf-repro/tree/cache-enabled-clobber
Participation
Astro Info
Describe the Bug
When a Cloudflare cache provider is configured (
cache: { provider: cacheCloudflare() }), the adapter force-enables the Workers Cache in the emitted config even when the project'swrangler.jsoncexplicitly sets"cache": { "enabled": false }. The builtdist/server/wrangler.jsoncomes out with"cache": { "enabled": true }, so the opt-out is silently rewritten.The check at
packages/integrations/cloudflare/src/wrangler.ts#L73isand
!config.cache?.enabledtreats "unset" and "explicitly false" the same.For context on why someone would set
enabled: falsewhile still using the provider: Workers Cache supports per-entrypoint enablement, e.g."exports": { "Render": { "type": "worker", "cache": { "enabled": true } } }with the default export left uncached. That shape is useful for an uncached gateway that derives cache-key dimensions (host, region) intoctx.propsand loops back into a cached named entrypoint viactx.exports, which seems to be the documented way to add key dimensions the platform does not provide. Theexportsblock passes through the customizer untouched; only the top-levelenabled: falsegets overridden. The workaround for now is post-processingdist/server/wrangler.jsonbetween build and deploy.What's the expected result?
An explicit
"cache": { "enabled": false }in the user's wrangler config survives the build. Checking forconfig.cache?.enabled === undefinedrather than falsiness would keep the current auto-enable default for configs that do not mentioncacheat all, while respecting an explicit opt-out.Link to Minimal Reproducible Example
https://github.com/skezo/astro-cf-repro/tree/cache-enabled-clobber
Participation