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 / Cache-Control handling so we can reproduce the missing header.
- Assistant
I'll look at AGENTS.md and the Cache-Control / gSSP-related server code next.
- Assistant
Let me look at cache-headers.ts, cache-control.ts, and pages-page-response.ts as well as anything related to gssp.
- Assistant
rg is not found - I need to use grep instead.
- Assistant
I'll inspect pages-page-response, pages-page-data, cache-control, and the related tests next.
- Assistant
Next I'll inspect where Cache-Control is set for gSSP responses and how page-data handles headers.
- Assistant
I'll examine applyGsspHeaders and how createGsspReqRes builds the mock response object.
- Assistant
Deploy mode is where the failures show up — I'll focus on the worker/prod gSSP path and default Cache-Control.
- Assistant
I'll open
pages-server-entry.tsaround createGsspReqRes and the response header path. - Assistant
I'll inspect pages-node-compat and the tests covering gSSP Cache-Control behavior.
- Assistant
I'll hunt down how Next.js sets gSSP Cache-Control and whether vinext has any matching coverage.
- Assistant
I'll check middleware header merging and the deploy/worker path for dropped Cache-Control.
- Assistant
I'll pull up the Next.js getServerSideProps Cache-Control expectations and scan AGENTS/docs for related context.
- Assistant
Let me look at how Next.js base-server handles this for gssp.
- Assistant
Let me look at pages-handler.js around line 484 for the gssp Cache-Control logic.
- Assistant
I'll inspect the data-route JSON response helpers and how they handle headers.
- Assistant
Let me also check getStaticProps with revalidate: 0 - that would set isrRevalidateSeconds:
- Assistant
Checking the ssr-headers fixture and how pages-router tests cover headers.
- Assistant
I'll inspect Cloudflare TPR header stripping and whether Cache-Control is filtered out.
- Assistant
Checking the dev server's streamPageToResponse path for Cache-Control defaults.
- Assistant
I'll check how Next decides cacheControl for getServerSideProps vs getStaticProps.
- Assistant
I'll look for where render sets cacheControl for getServerSideProps.
- Assistant
Implementing the fix: I'll update
renderPagesPageResponseand the data-request header path. - Assistant
Checking imports and header handling in the pages-server-entry template.
- Assistant
Applying the core fix in
pages-page-response.tsand fixing data-request header forwarding in the server entry. - Assistant
Now edit the Cache-Control section.
- Assistant
Next I'll fix data-request header forwarding in pages-server-entry.ts.
- Assistant
I'll put a shared header helper in pages-data-route so both data JSON and callers can reuse it cleanly.
- Assistant
Cleaning up residual broken comments left from the edit.
- Assistant
I need to remove the duplicate comment and fix the trailing broken comment after the function.
- Assistant
Checking the rest of the file is intact.
- Assistant
I'll import NEVER_CACHE_CONTROL and simplify the server-entry data path to use gsspRes.
- Assistant
Now replace the hardcoded string with NEVER_CACHE_CONTROL
- Assistant
Need to go to that line first.
- Assistant
Now I can replace.
- Assistant
Updating the pages-server-entry data path to pass gsspRes cleanly.
- Assistant
I'll also fix the dev-server path for gSSP Cache-Control parity.
- Assistant
Updating the dev server so gSSP Cache-Control defaults match production.
- Assistant
I'll track whether gSSP ran and apply the correct default Cache-Control.
- Assistant
I'll add hadGssp flag and update the header building + data requisition sections.
- Assistant
Now update the data req and extraHeaders sections.
- Assistant
Update data headers and HTML headers.
- Assistant
Now the HTML extraHeaders section.
- Assistant
Note: the comment says "ISR and font preload headers (which take precedence)" - but Next.js does NOT override user Cache-Control. I'll match Next.js.
- Assistant
Writing a temporary script to verify the Cache-Control behavior.
- Assistant
Need to run from vinext package where react is available.
- Assistant
There's already a vitest setup. Let me run the unit tests for pages-page-response.
- Assistant
I'll put the script inside the repo so Node can resolve packages.
- Assistant
The relative paths were wrong because the script was under tests/. Let me fix.
- Assistant
Typo in my script. First cases passed though. Fix and rerun.
- Assistant
I'm introducing tools typos because of AI garbled text. Let me write a clean file carefully.
- Assistant
Unit-level checks passed. Running existing unit tests and cleaning up the temp file.
- Assistant
The test timed out. Let me try differently - check how tests are run.
- Assistant
Let me try running vitest directly with a longer timeout.
- Assistant
vp test seems to hang. Let me try vitest directly.
- Assistant
vp is vite-plus. Let me check if there's something wrong withrunning tests or if I need to use a different approach.
- Assistant
Corepack is trying to download pnpm and hanging. Let me try using node_modules/.bin/vp directly.
- Assistant
Good. Now run pages-page-response and pages-data-route tests.
- Assistant
Unit tests pass. Checking whether dist needs a rebuild for integration tests.
- Assistant
Dist is outdated - needs rebuild forintegration tests that use the packaged code.
- Assistant
Build succeeded. Verify dist has the fix.
- Assistant
I'm inside packages/vinext already.
- Assistant
I'll run the focused pages-router header integration tests next.
- Assistant
That test passed. Let me also add a quick verification that cache-control is on ssr-headers. The geader test didn't assert Cache-Control though.
- Assistant
Verifying the full diff looked clean and no leftover temp files remain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.