File size: 1,658 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import { fetchCached, getCachedData } from './data-fetching'
export default async function Page() {
return (
<main>
<h1>Warmup Dev Renders</h1>
<p>
In Dev when cacheComponents is enabled requests are preceded by a cache
warming prerender. Without PPR this prerender only includes up to the
nearest Loading boundary (loading.tsx) and will never include the Page
itself. When PPR is enabled it will include everything that is
prerenderable including the page if appropriate.
</p>
<FetchingComponent />
<CachedFetchingComponent />
<CachedDataComponent />
</main>
)
}
async function CachedFetchingComponent() {
const data = await fetchCached(
'https://next-data-api-endpoint.vercel.app/api/random?key=cachedpage'
)
console.log('after cached page fetch')
return (
<dl>
<dt>
Cached Fetch
(https://next-data-api-endpoint.vercel.app/api/random?key=cachedpage)
</dt>
<dd>{data}</dd>
</dl>
)
}
async function FetchingComponent() {
const response = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random?key=uncachedpage'
)
console.log('after uncached page fetch')
const data = await response.text()
return (
<dl>
<dt>
Uncached Fetch
(https://next-data-api-endpoint.vercel.app/api/random?key=uncachedpage)
</dt>
<dd>{data}</dd>
</dl>
)
}
async function CachedDataComponent() {
const data = await getCachedData('page')
console.log('after page cache read')
return (
<dl>
<dt>Cached Data (Page)</dt>
<dd>{data}</dd>
</dl>
)
}
|