forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetch cache: revalidate should take precedence over force-dynamic (ve…
…rcel#72357) `force-dynamic` will automatically disable caching on a fetch. If `force-dynamic` is set, and there's a `revalidate` value on the fetch, the revalidate value will be a no-op unless you explicitly opt into caching via `cache: 'force-cache'`. This changes the behavior to favor a positive revalidate value over `force-dynamic` when deciding to cache the fetch.
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 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
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
19 changes: 19 additions & 0 deletions
19
test/e2e/app-dir/app-static/app/force-dynamic-fetch-cache/revalidate/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,19 @@ | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default async function Page() { | ||
const data = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random', | ||
{ | ||
next: { | ||
revalidate: 3, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
return ( | ||
<> | ||
<p id="page">/force-dynamic-fetch-cache/revalidate</p> | ||
<p id="data">{data}</p> | ||
</> | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
test/e2e/app-dir/logging/app/cache-revalidate/force-dynamic/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,14 @@ | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default async function Page() { | ||
const data = await fetch( | ||
'https://next-data-api-endpoint.vercel.app/api/random?revalidate-3', | ||
{ | ||
next: { | ||
revalidate: 3, | ||
}, | ||
} | ||
).then((res) => res.text()) | ||
|
||
return <div>Hello World! {data}</div> | ||
} |