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.Expected: "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.
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 callsubmit) usinggit statusorgit diffcommands. 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
Let me start by understanding the issue and exploring the repository structure. The issue is about Pages Router gssp (getServerSideProps/getStaticProps) responses missing default and user-set
Cache-Controlheaders in vinext.Let me first explore the repository structure to understand how it's organized.
Assistant
Let me explore the repository structure more systematically.
Assistant
Let me explore the packages directory since this is where the vinext package code is, and also look at the tests directory.
Assistant
Let me look at the tests directory and search for gssp-related test files.
Assistant
Let me look at the e2e tests and the pages-router related files:
Assistant
Let me search for gssp-related files, especially anything with "getserversideprops" or "gssp":
Assistant
Let me search specifically for gssp and Cache-Control to understand the issue better.
Assistant
Let me look at the server pages-related files to understand how gssp responses are handled. The issue is about Cache-Control headers not being set for gssp responses.
Assistant
Now I can see the issue. Looking at the
renderPagesPageResponsefunction, theCache-Controlheader is only set in two conditions:- When
options.scriptNonceis set →no-store, must-revalidate - When
options.isrRevalidateSecondsis set → ISR cache control
But for regular gssp responses (neither nonce nor ISR), the Cache-Control header is not set! The issue says the default should be
private, no-cache, no-store, max-age=0, must-revalidate.Also, I can see
applyGsspHeaderscopies headers fromgsspRes.getHeaders(), but after that function returns, the code then conditionally overrides Cache-Control. The problem is that when neither condition is met, no Cache-Control is set at all.Let me also look at the test files for the pages router to understand the expected behavior better:
- When
Assistant
Now I understand the issue better. Looking at the test file, I can see:
-
In the first test ("renders the document shell, merges gSSP headers..."), there's a
gsspReswith headers but the test doesn't check forCache-Control. However, in this scenario (gssp without ISR and without nonce), noCache-Controlis set. -
In the test "disables pages ISR caching when a script nonce is present", when there's a nonce,
Cache-Controlis set tono-store, must-revalidate.
-
Assistant
I found the constant
NEVER_CACHE_CONTROL = "private, no-cache, no-store, max-age=0, must-revalidate"which is exactly what the issue expects.Now let me understand the issue better. The problem is:
- When a gssp response is served (without nonce and without ISR), no
Cache-Controlheader is set at all - The user's
res.setHeader('Cache-Control', ...)calls should be preserved (which they are viaapplyGsspHeaders) - If the user didn't set it, we should apply the default
- When a gssp response is served (without nonce and without ISR), no
Assistant
I
Assistant
Let me look at this entry file more carefully to understand when
gsspResis null vs not null:Assistant
Let me look at the full context around the Cache-Control logic in
renderPagesPageResponse:Assistant
Actually, let me look at lines 300-350 where the Cache-Control logic is:
Assistant
Now I have a clear picture. The fix needs to:
- Import
NEVER_CACHE_CONTROLfrom./cache-control.js - After the
if/else ifblock for Cache-Control, add anelse ifthat checks if the user hasn't already set Cache-Control (via gsspRes), and if so, set the defaultNEVER_CACHE_CONTROL
Let me verify the import already exists:
- Import
Assistant
Good. I need to also import
NEVER_CACHE_CONTROL. Let me also look at the e2e test that was referenced in the issue:Assistant
Let me check the test for gssp headers and status:
Assistant
Now I need to understand what the test fixture looks like to see how gssp pages set headers. Let me find the test fixture:
Assistant
Now let me look at how the pages router test file handles this. I want to look at the test file more carefully to understand the test setup:
Assistant
Now let me look at the specific test case and understand if there's a test for Cache-Control already:
Assistant
Now let me also check if there's a test specifically for gssp default Cache-Control in the existing tests. Let me also look at the pages-page-response.test.ts more carefully:
Assistant
Now let me create a simple reproduction script first to confirm the issue. Let me create a test script that checks the behavior:
Assistant
Let me run the existing pages-page-response tests first to confirm they pass:
Assistant
The test timed out. Let me try a simpler approach - just make the fix first and verify by inspecting the code logic. Let me also look at how similar issues are handled elsewhere:
Assistant
Let me look at how
app-route-handler-response.tshandles this for reference:Assistant
Now I understand the pattern. The
NEVER_CACHE_CONTROLis used for route handlers when caching is disabled. Let me now implement the fix forpages-page-response.ts.The fix should be:
- Import
NEVER_CACHE_CONTROLfrom./cache-control.js - After the
if/else ifblock that sets Cache-Control, add anelse ifto set the defaultNEVER_CACHE_CONTROLwhen the user hasn't already set it (i.e., whengsspResis null or doesn't have acache-controlheader)
Let me implement the fix:
- Import
Assistant
Now I'll apply the fix. I need to:
- Add
NEVER_CACHE_CONTROLto the import from./cache-control.js - Add an
elseclause that sets the defaultNEVER_CACHE_CONTROLwhen the user hasn't setCache-Controlvia gsspRes
- Add
Assistant
Let me use the replace command instead:
Assistant
Now I need to modify the Cache-Control logic. Let me replace the current if/else if block with one that includes the else clause:
Assistant
Let me try with the correct format:
Assistant
Let me use the edit command with the correct line range:
Assistant
I see there's a duplicate line
if (options.fontLinkHeader) {. Let me fix that:Assistant
The fix looks correct now. Let me verify the full context of the changed section:
Assistant
Now let me create a simple test script to verify the fix logic works correctly. I'll write a minimal unit test:
Assistant
All the logic tests pass. Now let me also check if there are any existing tests that might be affected by this change. Let me look at the pages-page-response.test.ts to see if any test expects
nullfor Cache-Control in certain scenarios:Assistant
Good, those tests are for ISR and nonce cases which are not affected. Now let me look at the first test case which has a
gsspReswithout Cache-Control:Assistant
This test case has a
gsspReswith headers but nocache-control. After my fix, it should now haveCache-Control: private, no-cache, no-store, max-age=0, must-revalidate. The test doesn't explicitly check forcache-controlbeing null, so it should still pass.Now let me also check the common options -
gsspRes: nullmeans no gssp, so the default Cache-Control should be applied there too:Assistant
The common options use
gsspRes: nullandisrRevalidateSeconds: null, so after my fix, these tests should get the defaultNEVER_CACHE_CONTROLheader. Since none of the existing tests check forcache-controlbeingnullin these cases, they should still pass.Let me also check if there are any tests that might be expecting
nullcache-control in the pages-router tests:Assistant
Good - those are the nonce tests which are not affected by my change.
Now let me check if the fix is complete. Let me look at the entire modified section one more time to make sure the logic is correct:
Assistant
The logic looks correct. Let me verify by going through the scenarios:
- scriptNonce is set: Cache-Control is set to
no-store, must-revalidate✓ - isrRevalidateSeconds is set: Cache-Control is set to ISR value ✓
- User set Cache-Control via gsspRes:
applyGsspHeaderscopies it, andresponseHeaders.has("cache-control")is true, so we skip the default ✓ - No scriptNonce, no ISR, no user-set Cache-Control: The default
NEVER_CACHE_CONTROLis applied ✓
Now let me verify the fix doesn't break TypeScript by checking if the build works:
- scriptNonce is set: Cache-Control is set to
Assistant
Command exited with code 0,Current directory: /vinext, current file: /vinext/packages/vinext/src/server/pages-page-response.ts) bash-$
Assistant
Let me check the exit code and see if there were any issues.
I need to continue verifying my fix. Let me run a quick build check to make sure the TypeScript compiles correctly, and also verify the fix more thoroughly.
Assistant
TypeScript compiles successfully. Let me also check if there are any other places where gssp responses are handled that might need similar fixes:
Assistant
The command timed out. Let me continue investigating other places where Cache-Control headers might need to be set for gssp responses. I should check the pages-data-route.ts and pages-page-data.ts files to see if they also need the same fix.
Assistant
Let me check the pages-page-data.ts file to understand if it also needs the same fix for default Cache-Control headers.
Assistant
Looking at the
pages-page-data.tsfile, I can see that:- The
buildPagesCacheResponsefunction already sets Cache-Control for cached ISR responses usingbuildCachedRevalidateCacheControl. - The
resolvePagesPageDatafunction returns either a response or render result, but doesn't directly set Cache-Control for the gssp case - that's handled inpages-page-response.ts.
The
pages-data-route.tsfile might also need checking. Let me look at it to see if there's a separate path for gssp data routes that might also need the fix.But wait - the main fix I made is in
pages-page-response.tswhich is the core response builder for Pages Router HTML responses. This should cover the main case.Let me also check
pages-data-route.tsto see if there's a data route handler that might need similar treatment.- The
Assistant
Let me check how the data route handles gssp responses and whether it also needs the Cache-Control fix:
Assistant
The data route (
/_next/data/...) is a separate code path that usesbuildNextDataJsonResponse. Looking at the issue description, it specifically mentions the Pages Router gssp/getStaticProps responses for HTML pages, not the data route JSON responses. The issue mentions:Expected: "private, no-cache, no-store, max-age=0, must-revalidate" Received: null
This is about HTML responses. The data route JSON responses might have different caching requirements. Let me verify my fix is complete by looking at the test that was mentioned in the issue.
Let me now run the existing tests to make sure I didn't break anything. Let me try running a subset of tests.
Assistant
The test runner is timing out. Let me try a different approach - I'll try running the tests with the project's test command, or check how tests are run in this repository.
Assistant
Tests are timing out. Let me try a simpler approach - just verify the code compiles and the logic is correct by writing a simple test script.
Assistant
Let me verify my fix is correct and complete.
Assistant
The tests are timing out. Let me verify my changes are correct by reviewing the diff and ensuring the logic is sound.
Assistant
Let me verify my changes are complete. Let me also run a quick sanity check to make sure the TypeScript compiles correctly.
Assistant
The TypeScript check passed. Let me verify my fix is complete by reviewing the final state of the code and summarizing what was done:
Assistant
Now let me verify my changes are correct and submit them.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.