sveltejs / sveltejs/kit

generated `env.js` is missing a cache buster

Open
#13,799 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction and the generated build/_app/env.js output when using the static adapter with a public static environment variable. Trace how that file is generated and referenced; done means deployments produce a cache-busted env.js filename so Cloudflare does not reuse stale environment data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.