Missing Cache-Control
header in /404
rewrite response
#76168
Labels
Linking and Navigating
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/nextjs-404-missing-cache-control-xvggzv
To Reproduce
npm run build && npm start
curl -I http://localhost:3000/example
Current vs. Expected behavior
Current behavior
The response doesn't include a
Cache-Control
header:Expected behavior
The reponse should include an explicit
Cache-Control
header. I proposeprivate, no-cache, no-store, max-age=0, must-revalidate
to avoid caching.Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Available memory (MB): 4242 Available CPU cores: 2 Binaries: Node: 20.12.0 npm: 10.5.0 Yarn: 1.22.19 pnpm: 8.15.6 Relevant Packages: next: 15.1.7 // Latest available version is detected (15.1.7). eslint-config-next: 15.0.4 react: 19.0.0 react-dom: 19.0.0 typescript: 5.7.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Other (Deployed)
Additional context
I tested this behavior in Next v14 and v15.
My original motivation for rewriting a path to
/404
was rewriting non-existing/_next/static
URLs because for those we skip the middleware and they caused 500 errors in my page.tsx.The text was updated successfully, but these errors were encountered: