mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This makes some critical modifications to the app render pipeline when PPR has been enabled for pages with segments defining: ```js export const dynamic = "force-dynamic" ``` Importantly, it no longer modifies the revalidation time to zero for those pages, and now falls back to the provided default revalidation time. When static render occurs, if the page being rendered has a segment config defining `dynamic === "force-dynamic"`, then it will postpone at the root of the component tree. This ensures that no render code is executed for the page, as the entirety of the tree will have postponed. This fixes the bug where the flight prefetch wasn't generated correctly as well.
72 lines
1.8 KiB
JavaScript
72 lines
1.8 KiB
JavaScript
import { fetchRetry } from '../../../lib/fetch-retry'
|
|
|
|
export default async function Page() {
|
|
const data = await fetchRetry(
|
|
'https://next-data-api-endpoint.vercel.app/api/random',
|
|
{
|
|
method: 'POST',
|
|
next: {
|
|
revalidate: 10,
|
|
},
|
|
}
|
|
).then((res) => res.text())
|
|
|
|
const dataWithBody1 = await fetchRetry(
|
|
'https://next-data-api-endpoint.vercel.app/api/random',
|
|
{
|
|
method: 'POST',
|
|
body: JSON.stringify({ hello: 'world' }),
|
|
next: {
|
|
revalidate: 10,
|
|
},
|
|
}
|
|
).then((res) => res.text())
|
|
|
|
const dataWithBody2 = await fetchRetry(
|
|
'https://next-data-api-endpoint.vercel.app/api/random',
|
|
{
|
|
method: 'POST',
|
|
body: new ReadableStream({
|
|
start(controller) {
|
|
controller.enqueue(JSON.stringify({ another: 'one' }))
|
|
controller.close()
|
|
},
|
|
}),
|
|
duplex: 'half',
|
|
next: {
|
|
revalidate: 10,
|
|
},
|
|
}
|
|
).then((res) => res.text())
|
|
|
|
const dataWithBody3 = await fetchRetry(
|
|
'https://next-data-api-endpoint.vercel.app/api/random',
|
|
{
|
|
method: 'POST',
|
|
body: new URLSearchParams('myParam=myValue&myParam=anotherValue'),
|
|
next: {
|
|
revalidate: 30,
|
|
},
|
|
}
|
|
).then((res) => res.text())
|
|
|
|
const dataWithBody4 = await fetchRetry(
|
|
'https://next-data-api-endpoint.vercel.app/api/random',
|
|
{
|
|
method: 'POST',
|
|
body: new URLSearchParams('myParam=myValue&myParam=diffValue'),
|
|
}
|
|
).then((res) => res.text())
|
|
|
|
return (
|
|
<>
|
|
<p id="page">/variable-revalidate/post-method-cached</p>
|
|
<p id="page-data">{data}</p>
|
|
<p id="data-body1">{dataWithBody1}</p>
|
|
<p id="data-body2">{dataWithBody2}</p>
|
|
<p id="data-body3">{dataWithBody3}</p>
|
|
<p id="data-body4">{dataWithBody4}</p>
|
|
</>
|
|
)
|
|
}
|