Skip to content

generated env.js is missing a cache buster #13799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TorstenDittmann opened this issue May 16, 2025 · 1 comment
Open

generated env.js is missing a cache buster #13799

TorstenDittmann opened this issue May 16, 2025 · 1 comment

Comments

@TorstenDittmann
Copy link
Contributor

TorstenDittmann commented May 16, 2025

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

@TorstenDittmann TorstenDittmann changed the title generated env.js is missing a cache buster generated env.js is cached May 16, 2025
@TorstenDittmann TorstenDittmann changed the title generated env.js is cached generated env.js is missing a cache buster May 16, 2025
@TorstenDittmann
Copy link
Contributor Author

TorstenDittmann commented May 16, 2025

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 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant