mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
`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.
20 lines
379 B
JavaScript
20 lines
379 B
JavaScript
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>
|
|
</>
|
|
)
|
|
}
|