-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added cache control headers for static app routes (#72521)
This pull request includes several changes to improve cache control handling and add new test cases for verifying cache headers in the standalone mode of the application. Improvements to cache control handling: * [`packages/next/src/server/base-server.ts`](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3295-R3298): Updated cache control conditions to check for `undefined` explicitly before setting cache headers. [[1]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3295-R3298) [[2]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aL3318-R3324) [[3]](diffhunk://#diff-6f4291cc2bfc5073fdca12a014011769e840ee68583db1468acef075f037015aR3354-R3365) New test cases: * [`test/production/standalone-mode/required-server-files/required-server-files-app.test.ts`](diffhunk://#diff-0d083b6c7bd3a8a3e9c5ee854123ada3b72db58220d8b65912b047b082f834a2R104-R129): Added test cases to verify that the correct cache headers are sent for app routes and app pages. New static and dynamic route handlers: * `test/production/standalone-mode/required-server-files/app/api/test/[slug]/route.js`: Added a new dynamic route handler with forced static generation. ([test/production/standalone-mode/required-server-files/app/api/test/[slug]/route.jsR1-R7](diffhunk://#diff-1cf8a2cfdbb6473656b2456af0267556270fbbaa7ee2c37e2f3e6c6fed1e4d21R1-R7)) * `test/production/standalone-mode/required-server-files/app/test/[slug]/page.jsx`: Added a new static page with a revalidation interval and a function to generate static parameters. ([test/production/standalone-mode/required-server-files/app/test/[slug]/page.jsxR1-R9](diffhunk://#diff-32038443ca3e4f28db37a6543966397682c64cf6f34e6dd03fd8096414d23022R1-R9)) - Fixes #65814 Co-authored-by: Janka Uryga <[email protected]> Co-authored-by: Sam Ko <[email protected]>
- Loading branch information
1 parent
0fc77d9
commit 91e3479
Showing
5 changed files
with
71 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/production/standalone-mode/required-server-files/app/api/test/[slug]/route.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const dynamic = 'force-static' | ||
|
||
export async function GET(request, context) { | ||
const { params } = context | ||
const { slug } = params | ||
return Response.json({ message: `Hello, ${slug}!` }) | ||
} |
9 changes: 9 additions & 0 deletions
9
test/production/standalone-mode/required-server-files/app/test/[slug]/page.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const revalidate = 3600 | ||
|
||
export default function Page() { | ||
return <div>Hello, World!</div> | ||
} | ||
|
||
export async function generateStaticParams() { | ||
return [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters