-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Description
Link to the code that reproduces this issue
https://github.com/pieh/next-fallback-true-no-cache
To Reproduce
-
Clone https://github.com/pieh/next-fallback-true-no-cache repository.
-
Install deps, build and start the server:
npm install npm run build
-
Start the server:
npm start
-
Hit not-prerendered page (using example URL, but any will work other than "/prerendered" as there is cacheable catch-all page)
curl --head http://localhost:3000/not-prerendered
Notice the response headers (expected, this page was not prerendered and fallback was served, so should not be cached):
x-nextjs-cache: MISS Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
Now let's hit json endpoint to generate the page
curl --head http://localhost:3000/_next/data/build-id/not-prerendered.json
Notice the response headers: (expected, page was not rendered and cached yet, so we get cache miss, but we do get cacheable cache-control header as expected with revalidate:3600)
x-nextjs-cache: MISS Cache-Control: s-maxage=3600, stale-while-revalidate=31532400
At this point next html response should not be fallback anymore, should be cache hit and should have cacheable cache-control header, so let's hit the page again:
curl --head http://localhost:3000/not-prerendered
Notice the response headers: (NOT expected, page was served from the cache, but cache-control won't allow to cache it):
x-nextjs-cache: HIT Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
Current vs. Expected behavior
Expected Cache-control
header when hitting HTML route after page was generated and fallback was not served anymore should be s-maxage=3600, stale-while-revalidate=31532400
as it was for the json endpoint, but instead got not cacheable private, no-cache, no-store, max-age=0, must-revalidate
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020
Available memory (MB): 32768
Available CPU cores: 12
Binaries:
Node: 22.13.1
npm: 10.9.2
Yarn: 1.22.22
pnpm: N/A
Relevant Packages:
next: 15.4.0-canary.94 // Latest available version is detected (15.4.0-canary.94).
eslint-config-next: N/A
react: 19.1.0
react-dom: 19.1.0
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Pages Router, Dynamic Routes
Which stage(s) are affected? (Select all that apply)
next start (local)
Additional context
Last version this worked as expected was [email protected]
. 15.4.0-canary.78
canary is first one that has this regression.