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-related code.
- Assistant
Let me search for Cache-Control with grep instead of rg.
- Assistant
I'll read the pages-page response path and Cache-Control utilities next.
- Assistant
I'll inspect Cache-Control application and header forwarding in the pages response path.
- Assistant
Let me read more of the file, particularly the applyGsspHeaders and Cache-Control sections.
- Assistant
Let me see the rest of the file around Cache-Control.
- Assistant
I'll inspect gssp header collection, the data route path, and how the default Cache-Control is applied in production vs dev.
- Assistant
Looking at dev-server around line 1057:
- Assistant
The issue is about deploy mode (vinext production / Cloudflare Workers) based on "Next.js Deploy Suite". So pages-page-response.ts and related production path is the main focus.
- Assistant
There's already a pages-page-response.test.ts - let me look at that and the createGsspReqRes in pages-server-entry.
- Assistant
Let me track down createPagesReqRes and any places where Cache-Control defaults might be missing.
- Assistant
Let me read pages-node-compat.ts for how setHeader works
- Assistant
Let me continue reading the createPagesReqRes function
- Assistant
I'll check getHeaders next so we understand what applyGsspHeaders receives.
- Assistant
I'll check pages-server-entry where gssp response headers get applied to the final response.
- Assistant
Need to open the right file
- Assistant
There's a likely bug: data-req path uses
gsspRes.headersinstead ofgetHeaders(). Checking Next.js test expectations and JSON data response helper next. - Assistant
I'll look up Next.js default Cache-Control for gSSP and any vinext notes about this issue.
- Assistant
I'll inspect the gSSP header fixture and whether prod-server filters Cache-Control.
- Assistant
I'll study how App Router and related helpers apply default Cache-Control headers.
- Assistant
I'll grab the relevant Next.js getServerSideProps tests for expected Cache-Control behavior.
- Assistant
Let me sparse-checkout the relevant files.
- Assistant
Need different sparse checkout approach
- Assistant
Good. Let me search for Cache-Control in the getserversideprops tests.
- Assistant
Let me look at the test around line 824 and the render.tsx around line 572.
- Assistant
I'll inspect custom-cache setup and where gSSP default Cache-Control is applied.
- Assistant
I'll inspect how pages-page-data assigns isrRevalidateSeconds for static and gSSP pages.
- Assistant
Continue reading from 490
- Assistant
I'll check how Next.js treats revalidate: 0 and Cache-Control for getStaticProps.
- Assistant
Next I'll check whether middleware or the request pipeline strips Cache-Control after the response is built.
- Assistant
I'll implement the fix in pages-page-response and the data-request path, then add tests.
- Assistant
I'll update the response helper and entry data path, then add unit tests for Cache-Control defaults and overrides.
- Assistant
I'll make the changes now.
- Assistant
Updating header helpers and Cache-Control application next.
- Assistant
I need to clean up the typos and restore Content-Type override behavior in applyGsspHeaders.
- Assistant
Now update the call site in renderPagesPageResponse.
- Assistant
There's something wrong - lines 381 and 394 both set NEVER_CACHE. Let me read the full section around buildGsspNextDataHeaders.
- Assistant
There's leftover duplicate code from a bad edit. I need to remove lines 386-398.
- Assistant
Need a blank line before export async function and fix then cache control section.
- Assistant
I messed up the file with partial edits. Restoring the file tail cleanly.
- Assistant
I'll replace from line 387 to end with the correct function body.
- Assistant
I'll wire
buildGsspNextDataHeadersinto the pages-server-entry data path next. - Assistant
I'll update the import and the data request block.
- Assistant
Now fix the isDataReq body
- Assistant
I'll also update the dev-server Cache-Control path so gSSP defaults stay consistent there.
- Assistant
Looking at细节 where is data req for authenticated iners dev-server... Does dev-server handle _next/data?
Also from getserversideprops tests - they run in production (the branches are under
} else {which is!dev based on line 800). Deploy suite is production.I'll still fix dev-server for consistency.
- Assistant
Need to find where gssp is tracked in's product - is there a flag for whether gssp ran?
- Assistant
I need a flag took track if gssp ran. Let me edit the header building section.
- Assistant
Now update the extraHeaders block around 1057
- Assistant
Also need to check if theres isDataReq short circuit earlier that returns without Cache-Control.
- Assistant
Check if isDataReq has a separate path indur dev-server that returns JSON earlier.
- Assistant
Look at line 859
- Assistant
Need to fix dev data path too for default Cache-Control.
- Assistant
There's an extra
}on line 879 - I need to remove it. - Assistant
I'll add unit tests and fixture pages for the default and custom Cache-Control paths.
- Assistant
I'll add tests after the array-valued headers test.
- Assistant
Also add tests for buildGsspNextDataHeaders. Import it in the test file.
- Assistant
Add a describe for buildGsspNextDataHeaders at end of file.
- Assistant
There's a test that checks scriptNonce sets no-store even without gssp. Our applyPagesCacheControl still does that when no user cache. Good.
- Assistant
There's a duplicate expect line 374-375 - that was from my edit. Let me fix it.
- Assistant
I'll add fixture pages and a couple of router assertions for the default and custom Cache-Control cases.
- Assistant
I'll update the SSR test to check cache-control and add a custom-cache test.
- Assistant
Add custom-cache test after ssr-headers test.
- Assistant
First I'll run the unit tests, then check if the production section needs the same Cache-Control asserts.
- Assistant
Timed out. Let me try vp test run.
- Assistant
Let me check package.json scripts
- Assistant
vp is in node_modules/.bin
- Assistant
Unit tests pass. I'll run the filtered pages-router Cache-Control tests next.
- Assistant
Dev integration tests pass. Now check production section for pages-router tests that might mirror gssp.
- Assistant
There may be production SSR/data-route coverage around lineدرسة 2746 — I'll extend that too.
- Assistant
I'll extend the production SSR and data-endpoint tests with Cache-Control expects.
- Assistant
Update data endpoint tests
- Assistant
I'll run the production data-endpoint and end-to-end SSR tests that cover Cache-Control.
- Assistant
All 13 passed including production. I'll do a final sanity check on the edited response file.
- Assistant
I'll check the final diff for cleanliness before submitting.
- Assistant
Confirming the custom-cache fixture is present and will be included.
- Assistant
Untracked files won't be in
git diff, so I'll stage the new fixture before submit. - Assistant
I'll confirm what
submitdiffs against so the staged fixture is included. - Assistant
I'll use intent-to-add so the new fixture is included in the submit diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.