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.
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) 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 to understand the codebase and then locate the relevant code for handling gssp (getServerSideProps) responses.
Assistant
Let me explore the repository structure more, particularly looking for test files related to gssp (getServerSideProps) and the source code that handles pages router responses.
Assistant
Let me look at the test files mentioned in the issue and the gssp-related files:
Assistant
Now let me look at the source code for handling gssp responses:
Assistant
Now let me look at the
pages-page-response.tsfile to understand how responses are built:Assistant
Now I can see the issue. In
renderPagesPageResponse, theCache-Controlheader is only set for:scriptNoncepages:"no-store, must-revalidate"- ISR pages (
isrRevalidateSeconds): usesbuildRevalidateCacheControl
But when it's a gssp page (when
gsspResis not null), there's no defaultCache-Controlheader being set. Let me also check what happens whengsspReshas headers set by the user - theapplyGsspHeadersfunction does copy headers fromgsspRes.getHeaders(), but theCache-Controlmay not be set if the user doesn't explicitly set it.Let me look at the test file referenced in the issue to understand the expected behavior:
Assistant
Let me search for tests related to Cache-Control headers for gssp:
Assistant
Let me search for the default gssp Cache-Control pattern that Next.js uses:
Assistant
Good, the constant
NEVER_CACHE_CONTROLalready exists. Now let me look at the cache-control module:Assistant
Now let me look at the
pages-page-response.tsmore carefully. The issue is inrenderPagesPageResponse- when there's a gssp page (gsspRes is not null), the Cache-Control header should be set toNEVER_CACHE_CONTROLunless the user explicitly set it. Let me see the flow:Assistant
I can see the issue now. Looking at the code flow:
applyGsspHeaders(responseHeaders, options.gsspRes)is called which copies headers fromgsspRes.getHeaders()toresponseHeaders- Then the Cache-Control is set based on:
scriptNonce→"no-store, must-revalidate"isrRevalidateSeconds→ usesbuildRevalidateCacheControl
- But if it's a gssp page (gsspRes is not null) and neither
scriptNoncenorisrRevalidateSecondsare set, no Cache-Control header is applied!
The fix should be:
- After
applyGsspHeaders, if this is a gssp page AND Cache-Control hasn't been set yet (not by user and not by ISR), we should set the defaultNEVER_CACHE_CONTROLheader.
Let me check the
applyGsspHeadersfunction to understand if user-set headers are already applied:Assistant
So
applyGsspHeaderscopies all headers from gsspRes (including user-set Cache-Control if any). Then the Cache-Control logic checks forscriptNonceorisrRevalidateSeconds, but neither of these applies to pure gssp pages. So for gssp pages:- If the user sets Cache-Control via
res.setHeader(), it gets copied byapplyGsspHeaders✓ - If the user doesn't set Cache-Control, it should default to
NEVER_CACHE_CONTROL✗ (missing!)
Now I understand the bug. The fix should add an else clause that sets
NEVER_CACHE_CONTROLfor gssp pages. Let me look at the existing tests to understand what behavior we need:- If the user sets Cache-Control via
Assistant
Now I have a clear understanding of the issue. Let me look at the e2e test for pages router gssp that's mentioned in the issue:
Assistant
Now let me write a simple script to reproduce the issue first:
Assistant
The source files are TypeScript, so I need to use a different approach. Let me check if the tests can be run directly:
Assistant
Let me skip the timeout issue and check what test runner the project uses:
Assistant
Let me understand the issue better by reading the code more carefully and make the fix:
Assistant
Now I need to:
- Import
NEVER_CACHE_CONTROLfrom./cache-control.js - Add logic to set the default Cache-Control header for gssp pages when not already set
Let me open the file and make the fix:
- Import
Assistant
Now I need to:
- Import
NEVER_CACHE_CONTROLfrom./cache-control.js - Modify the logic that sets Cache-Control to also handle gssp pages
Let me first update the import:
- Import
Assistant
I need to use the edit command with the correct syntax. Let me try using the
--fileoption.Assistant
Good, the import is updated. Now I need to find and update the Cache-Control logic. Let me scroll down to the relevant section:
Assistant
I need to continue scrolling to find the Cache-Control logic that needs to be updated.
Assistant
Now I can see the exact code that needs to be modified. Lines 379-387 handle Cache-Control, but they miss the case for gssp pages. I need to add an else clause that sets the default
NEVER_CACHE_CONTROLfor gssp pages when the user hasn't set it.Let me make the fix:
Assistant
The code looks good. Now let me verify my changes by viewing the complete modified file section:
Assistant
Good, the import is correct. Now let me verify the complete modified section with Cache-Control:
Assistant
The fix looks correct. Now let me add a test to the existing test file to validate this fix. Let me check the existing test file structure:
Assistant
Now let me also check what happens in the data request path. Let me look at
resolvePagesPageDatainpages-page-data.ts:Assistant
That's for ISR cache responses which is fine. Now let me run the existing tests to make sure I haven't broken anything:
Assistant
It seems the test is taking too long. Let me try to run just the specific test file for pages-page-response.
Assistant
The test is timing out. Let me try a different approach - build the package and verify the TypeScript compiles correctly:
Assistant
The build is timing out. Let me try compiling just the TypeScript file I changed to check for syntax errors:
Assistant
The errors are unrelated to my change - they're module resolution issues. Let me check if there's a tsconfig that handles these paths:
Assistant
The TypeScript compilation passes. Now let me verify by creating a simple test script that tests the logic. Let me also look at the existing tests more carefully:
Assistant
Let me check the git diff to see the changes I've made:
Assistant
The changes look correct. Now let me verify the fix works by writing a simple test script that can run with the project's test infrastructure. First, let me check if there are any e2e tests that might be affected:
Assistant
Let me check that ISR test to make sure my changes don't break ISR:
Assistant
Good. This ISR test is for ISR pages (with
getStaticPropsandrevalidate), not for gssp pages. My fix only applies whengsspResis present andisrRevalidateSecondsis null, so ISR pages won't be affected.Let me also check the pages-router.test.ts to see if there are any tests that check gssp Cache-Control:
Assistant
This is for a nonce test (
mw-csp-nonce=pages-isr), not for gssp. The"no-store, must-revalidate"comes from thescriptNoncebranch in the code.Now let me write a small test script that confirms my fix works correctly:
Assistant
I need to rebuild the dist to test my changes. Let me try running the build.
Assistant
The build is asking for confirmation. Let me try a different approach - I'll use the existing dist files and just manually update the compiled JS file, or try to confirm the download.
Assistant
The user seems to have encountered an error. Let me continue with the task. I need to rebuild the dist to test my changes. Let me try a different approach.
Assistant
The build completed successfully. Now let me run my test script to verify the fix works:
Assistant
All three tests pass. Let me clean up my test file and run the existing tests to verify I haven't broken anything.
Assistant
Now let me run the existing unit tests to make sure I haven't broken anything:
Assistant
All tests pass. Let me verify my final changes one more time:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.