-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cache: "default"
shouldn't get cached in route handlers (#70937)
In Next 15, route handlers should no longer cache any `fetch` requests by default. We do this by bailing out of caching if no explicit cache config is defined. However, this misses the case where `cache: "default"` is specified. Since the default caching behavior is to not cache, this should also opt into the automatic no cache behavior. This adds a test for the route handler and still validates that it doesn't impact page-level ISR cache.
- Loading branch information
Showing
4 changed files
with
87 additions
and
1 deletion.
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
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
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/app-static/app/(new)/default-config-fetch/api/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,10 @@ | ||
import { NextResponse } from 'next/server' | ||
|
||
export async function GET() { | ||
const data = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?default-config-fetch', | ||
{ cache: 'default' } | ||
).then((res) => res.text()) | ||
|
||
return NextResponse.json({ data }) | ||
} |
13 changes: 13 additions & 0 deletions
13
test/e2e/app-dir/app-static/app/(new)/default-config-fetch/page.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,13 @@ | ||
export default async function Page() { | ||
const data = await fetch( | ||
`https://next-data-api-endpoint.vercel.app/api/random`, | ||
{ cache: 'default' } | ||
).then((res) => res.text()) | ||
|
||
return ( | ||
<> | ||
<p>/default-config-fetch</p> | ||
<p id="data">{data}</p> | ||
</> | ||
) | ||
} |