kit
kit copied to clipboard
generated `env.js` is missing a cache buster
Describe the bug
We have been running into issues with deployments and realized that /_app/env.js is cached by cloudflare due to a missing cache buster in the filename.
A similiar issue could happen with /_app/version.json, but JSON files are usually not cached by the common cloudflare presets.
For now we have disabled cache for that path 👍🏻
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-fsrnypku?file=build%2F_app%2Fenv.js
Using the static adapter and a public static env var.
Logs
# not important
System Info
System:
OS: macOS 15.4.1
CPU: (11) arm64 Apple M3 Pro
Memory: 95.47 MB / 18.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.19.1 - ~/.nvm/versions/node/v20.19.1/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v20.19.1/bin/npm
pnpm: 10.7.0 - ~/.nvm/versions/node/v20.19.1/bin/pnpm
bun: 1.2.13 - ~/.bun/bin/bun
Browsers:
Chrome: 136.0.7103.114
Safari: 18.4
npmPackages:
@sveltejs/adapter-static: ^3.0.8 => 3.0.8
@sveltejs/kit: ^2.20.2 => 2.20.2
@sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
svelte: ^5.25.3 => 5.25.3
vite: ^6.2.3 => 6.2.3
Severity
serious, but I can work around it
Additional Information
No response
Actually I just saw what the node adapter is doing by only adding cache headers to /_app/immutable/ files:
https://github.com/sveltejs/kit/blob/main/packages/adapter-node/src/handler.js#L57-L59
This looks to be intended and should probably be mentioned in the docs for static adapters 👍🏻