Files
JJ KasperandGitHub 8c7e4f9bc4 Fix fetchCache config and On-Demand Revalidate handling (#47803)
This ensures we properly honor the `export const fetchCache` config and
also ensures we properly bypass fetch-cache when an On-Demand
Revalidation is occurring.

The `export const dynamic` handling is not changed here as that was
behaving correctly and should not influence fetch cache handling only
whether a page is prerendered fully or treated as SSR.

Fixes: https://github.com/vercel/next.js/issues/47273
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1679078572123979)
2023-04-01 21:15:13 -07:00

22 lines
466 B
JavaScript

import { cache, use } from 'react'
export const fetchCache = 'force-no-store'
export default function Page() {
const getData = cache(() =>
fetch('https://next-data-api-endpoint.vercel.app/api/random?page', {}).then(
(res) => res.text()
)
)
const dataPromise = getData()
const data = use(dataPromise)
return (
<>
<p id="page">/force-no-store</p>
<p id="page-data">{data}</p>
<p id="now">{Date.now()}</p>
</>
)
}