ISSUE DESCRIPTION Pages Router: gssp/getStaticProps responses missing default and…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. - Assistant
I'll start by exploring the repository structure and locating the Pages Router / gssp handling code related to Cache-Control headers.
- Assistant
I'll search the codebase for Cache-Control handling and getServerSideProps paths.
- Assistant
The rg didn't output results - maybe the path or type filter is wrong. Let me try again.
- Assistant
There's cache-control.ts, cache-headers.ts, and pages-page-response.ts — I'll inspect those next.
- Assistant
Inspecting pages-page-response.ts and related GSSP header handling.
- Assistant
Let me read the relevant parts of pages-page-response.ts around Cache-Control.
- Assistant
I'll look for
applyGsspHeadersand how GSSP responses set headers today. - Assistant
Let me look at applyGsspHeaders and pages-page-data, and pages-server-entry for how headers are handled.
- Assistant
Looking at the Cache-Control logic again:
- Assistant
There's an issue in the data req path - it uses
gsspRes.headersbut the type hasgetHeaders(). Let me look at pages-node-compat more carefully and also pages-page-data. - Assistant
Let me look at more of pages-node-compat and pages-page-data for GSSP, and also check related tests.
- Assistant
I'll check getHeaders and whether anything strips Cache-Control later in the response pipeline.
- Assistant
Checking prod-server and nitro path for Cache-Control stripping, and reading the existing pages-page-response tests.
- Assistant
Checking Next.js semantics and any notes in AGENTS.md about Cache-Control.
- Assistant
I'll look at how the app router applies the default NEVER_CACHE and preserves user headers so we can mirror that.
- Assistant
Checking git history and deploy/worker response finalization for header stripping.
- Assistant
Let me look at the Next.js test for getserversideprops to understand what exactly is expected. Maybe it's in node_modules or somewhere cached.
- Assistant
Let me find next.js test content for getserversideprops Cache-Control.
- Assistant
Inspecting Next.js pages-handler for when it sets Cache-Control on GSSP responses.
- Assistant
Key Next.js logic around 358-402:
- Assistant
Checking whether Cloudflare/deploy strips headers, and fixing the data-request path that reads
gsspRes.headersinstead ofgetHeaders(). - Assistant
Let me check pages-data-route and also look at tests for getserversideprops in the Next.js suite or scripts that reference it.
- Assistant
There's fixture coverage under pages-basic — I'll inspect how GSSP Cache-Control is tested there.
- Assistant
Inspecting the SSR headers fixture and any existing Cache-Control assertions.
- Assistant
Looking at Next.js getCacheControlHeader for revalidate: 0:
- Assistant
Looking at pages-router.test.ts around the ssr-headers assertions next.
- Assistant
Checking how getStaticProps without revalidate is handled:
- Assistant
I'll try to fetch the Next.js getServerSideProps e2e test that expects those Cache-Control headers.
- Assistant
Confirmed: HTML and
_next/databoth need the default and custom Cache-Control. Checking the full test and the data request path. - Assistant
The pages-server-entry is a generated template string — I'll inspect how it's constructed so I can fix both the HTML and data paths.
- Assistant
Implementing the fix: setting default Cache-Control on GSSP HTML responses, and forwarding getHeaders() + the default on data responses.
- Assistant
I'll implement the code changes now.
- Assistant
I edited the wrong file — restoring
app-page-response.tsand applying the change topages-page-response.ts. - Assistant
Now let me edit pages-page-response.ts correctly.
- Assistant
Updating the Cache-Control assignment at the end of
renderPagesPageResponse. - Assistant
Need to goto that line first.
- Assistant
Now I can replace.
- Assistant
I'll centralize data-response header handling in
pages-data-route.tsand fix the server entry path. - Assistant
Updating
buildNextDataJsonResponseand the server-entry data path next. - Assistant
Need to goto line 88 first.
- Assistant
I'll edit the file with a multi-part approach.
- Assistant
Need to add the import for NEVER_CACHE_CONTROL
- Assistant
goto first
- Assistant
I need to import after the comment block.
- Assistant
Fixing the data path in pages-server-entry to use
getHeaders()instead of.headers. - Assistant
I'll fix the gsspRes.headers to use getHeaders(), and also apply ISR cache control when apropriado. Also need check if buildRevalidateCacheControl is available in the generated entry.
- Assistant
I'll just fix getHeaders and optionally pass isr cache control:
- Assistant
Checking whether the dev-server has a separate pages path that also needs this fix.
- Assistant
There's a separate chu path in petroleum-server for GSSP. I'll inspect and fix it if needed for consistency.
- Assistant
Checking how` gsspExtraHeaders is filled and fixing theients O dev-server default Cache-Control.
- Assistant
I'll update the dev-server to apply the same Cache-Control defaults for consistency.
- Assistant
Let me sense more of imports around line 10-50 and then apply fixes.
- Assistant
I'll update the dev-server with the NEVER_CACHE_CONTROLmix import and the two places that set headers.
- Assistant
Now update the header assignment places in dev-server.
- Assistant
Update data path and HTML path.
- Assistant
Now Fix the HTML path in the truth-server around extraHeaders.
- Assistant
Update the HTML header logic.
- Assistant
Fixing the typo in the comment.
- Assistant
Rebuilding and running the related unit tests.
- Assistant
The build timed out — I'll retry with a clearer command.
- Assistant
Corepack is prompting for confirmation — bypassing that and running the build directly.
- Assistant
There's vp in node_modules. Let me checkscripts and build with vite.
- Assistant
Build succeeded. Running the relevant unit tests next.
- Assistant
Existing tests pass. Writing a temporary script to verify default and custom Cache-Control behavior.
- Assistant
Need to run from monorepo root so react resolves.
- Assistant
Verifying the final diff and running a few more related tests.
- Assistant
Confirming
app-page-response.tsis clean, then submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.