Pages Router: gssp/getStaticProps responses missing default and user-set Cache-Control…
- User
Pages Router: gssp/getStaticProps responses missing default and user-set
Cache-ControlheaderThis issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext
mainvs Next.jsv16.2.6, 2026-05-22).Problem
Pages Router gssp responses lack
Cache-Controlheaders. Tests expect the defaultprivate, no-cache, no-store, max-age=0, must-revalidatefor gssp pages and custom values set viares.setHeader('Cache-Control', ...), but vinext returnsnull. The default header is not applied and usersetHeadercalls are dropped.Expected: "private, no-cache, no-store, max-age=0, must-revalidate" Received: nullEstimated Impact
~2 test failures across the deploy suite.
Affected Test Suites
test/e2e/getserversideprops/test/index.test.ts(2 failures)
Recommendation
-
Reproduce first in vinext's own test suite. Add a Pages Router gssp page and assert the response carries the default
Cache-Controlheader; add a second page that overrides it viares.setHeaderand assert the override sticks. -
Emit the default gssp Cache-Control. When serving a gssp response in deploy mode, set
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidateunless the user set it explicitly. -
Preserve
res.setHeaderoverrides. Make sure headers set during gssp dispatch are forwarded to the final HTTP response.
Interface
No new interfaces are introduced.
- Assistant
I'll trace how Pages Router handles
getServerSidePropsresponses and whereCache-Controlshould be set. - Assistant
Implementing centralized gSSP Cache-Control handling and adding tests.
- Assistant
Fixing
buildPagesGsspDataResponseInit: it shouldn't forceContent-Type: text/htmlon JSON data responses. - Assistant
Adding a dev-server wrapper for
res.end()short-circuits and default Cache-Control on the normal gSSP path. - Assistant
Restoring the accidentally removed test and adding gSSP Cache-Control tests.
- Assistant
Fixed missing
Cache-Controlheaders on Pages RoutergetServerSidePropsresponses.Root cause
renderPagesPageResponseforwarded gSSP headers viares.setHeader(), but only setCache-Controlfor ISR pages or CSP nonce requests — not for normal gSSP pages. The/_next/data/...jsonpath also read a non-existentgsspRes.headersproperty instead ofgetHeaders(), so user overrides were dropped there.Changes
-
pages-page-response.ts— Centralized cache policy:- Default gSSP:
private, no-cache, no-store, max-age=0, must-revalidate(NEVER_CACHE_CONTROL) - User
res.setHeader('Cache-Control', ...)still wins - Added
buildPagesGsspDataResponseInit()for/_next/dataresponses - Added for short-circuits
- Default gSSP:
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.