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.codeExpected: "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
Investigating how Pages Router
getServerSidePropshandlesCache-Controland where headers are dropped. - Assistant
Implementing the fix: adding a shared helper and updating production, dev, and data-request paths.
- Assistant
Fixed Pages Router
getServerSidePropsresponses missingCache-Controlheaders.Root cause
gSSP responses only set
Cache-Controlfor ISR pages or CSP nonce pages. Plain gSSP pages got no default header, and the/_next/datapath in production had a separate bug: it readgsspRes.headersinstead ofgsspRes.getHeaders(), so user-set headers (includingCache-Control) were dropped on data requests.Changes
-
cache-control.ts— AddedsetDefaultPagesGsspCacheControl()using Next.js’s default:private, no-cache, no-store, max-age=0, must-revalidate -
pages-page-response.ts— After applying gSSP headers, sets the default whengsspResis present and noCache-Controlwas set (user overrides viares.setHeaderare preserved). -
dev-server.ts— Same default for HTML and/_next/dataJSON responses in dev. -
— Fixed data-request header forwarding to use , and applies the 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.