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
Now let me look at the exact data-request branch in pages-server-entry.ts and check how
gsspResis typed there: - Assistant
Now I'll make the fix. First,
pages-page-response.ts— emit the default gssp Cache-Control when the user hasn't set one: - Assistant
Now add unit tests. Let me update
tests/pages-page-response.test.ts: - Assistant
Unit tests pass. Now let's add the e2e reproduction. Check the existing pages-router ssr spec:
- Assistant
Adding a new fixture page is safe (tests use
findRoute, not exhaustive lists). Create the custom-cache fixture page: - Assistant
Now add the integration test assertions in
tests/pages-router.test.ts: - Assistant
My new integration tests run against the dev server (
startFixtureServer), which usesdev-server.ts, notpages-page-response.ts. Let me check the dev-server gssp header code and apply the same default there for parity: - Assistant
Now the big integration suite (dev + prod server paths):
- Assistant
All pass in dev-server path. Let me also add a production-path assertion — check the production SSR streaming describe:
- Assistant
This describe has a full prod server over the same fixture — I'll add the prod-path assertions here:
- Assistant
All pass. Let me run the full test suite in the background to catch any regressions, and meanwhile double-check lint/format:
- Assistant
The formatter hit an
EAGAINspawn failure — likely resource contention with the full test suite running in the background. I'll retry after it finishes. Let me wait for the background run: - Assistant
Let me add data-endpoint assertions in that prod describe:
- Assistant
The background full-suite run started before these last edits; let me check its status and then re-run the pages-router suite:
- Assistant
While the full suite runs, let me review the complete diff:
- Assistant
The suite is still running. I'll wait for its completion notification before finishing up.
- Assistant
That was the redundant waiter I killed — expected. Still waiting on the full suite.
- Assistant
I'll wait for the suite completion notification.
- Assistant
While waiting, let me save a note about the environment quirk I hit:
- Assistant
The full suite is still running. Waiting on the monitor notification before final verification (fmt + suite results).
- Assistant
Suite is actively running. Waiting for completion.
- Assistant
Waiting on the suite — I'll act when the monitor fires.
- Assistant
Standing by for the suite result.
- Assistant
The full test suite is still running in the background (task
bmd0zro3m); the monitorbx8t0ufq0will notify me when it exits. Once it completes I'll verify the results and run the formatter check.Work completed so far:
packages/vinext/src/server/pages-page-response.ts— gssp HTML responses now get Next.js' defaultCache-Control: private, no-cache, no-store, max-age=0, must-revalidateunless the user already set one viares.setHeader(whichapplyGsspHeaderscopies in first, so overrides win).packages/vinext/src/entries/pages-server-entry.ts— fixed the_next/databranch reading a non-existentgsspRes.headersproperty (usersetHeadercalls were silently dropped on data requests); it now usesgetHeaders()and applies the same never-cache default when the user didn't set one.packages/vinext/src/server/dev-server.ts— same default for gssp HTML and_next/dataresponses in dev, honoring user/middleware-set Cache-Control.- Tests — 3 new unit tests (), a new fixture page , and 8 new integration assertions across dev-server, prod-server HTML, and paths (, 247 passing).
- Assistant
Suite still running — continuing to wait for the monitor notification.
- Assistant
Still running. Waiting for the completion notification.
- Assistant
Still running (large suite, ~191 files). Waiting.
- Assistant
Still running — note the suite task has a 10-minute cap, so it may time out. If so, I'll split the run into chunks. Waiting for its notification.
- Assistant
Waiting for suite completion or timeout notification.
- Assistant
Still running. I'll keep waiting for the actual completion notification.
- Assistant
Waiting.
- Assistant
The suite mostly passed (3717/3722) but hit worker-spawn EAGAIN errors on this constrained machine. Let me identify which files/tests failed:
- Assistant
The bounded full-suite re-run is in progress (task
biebr0gtn, full log at/tmp/full-test-run.log). I'll check the failures once it completes. - Assistant
Progressing well — 178 files passed so far, no failures yet. Waiting for completion.
- Assistant
All checks pass. Let me update the memory note with the working mitigation:
- Assistant
Done. Summary of the fix for the missing
Cache-Controlheader on Pages Router gssp responses:Root causes
- No default header emitted.
renderPagesPageResponse()only setCache-Controlfor CSP-nonce and ISR responses — plain gssp renders got no header at all (nullin the deploy suite). - User
setHeaderdropped on_next/datarequests. The generated pages server entry read , a property that doesn't exist on the reqres object (it exposes ), so all gssp-set headers were silently discarded for data requests.
- No default header emitted.
- Assistant
That's the stale completion monitor timing out — the suite it was watching already finished and the bounded re-run verified everything green. No action needed; the task is complete:
- Fix: gssp responses now emit the default
Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate(prod render path, dev server, and_next/data), and userres.setHeader('Cache-Control', ...)overrides are preserved — including on data requests, where agsspRes.headersvsgetHeaders()bug was dropping all gssp-set headers. - Verified: typecheck, lint, fmt clean; full suite
--maxWorkers=4passed 212 files / 6227 tests with 0 failures.
- Fix: gssp responses now emit the default
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.