mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Continuation of https://github.com/vercel/next.js/pull/34498 this updates to send a `purpose: prefetch` header (related [w3c discussion](https://github.com/w3c/resource-hints/issues/74)) when prefetching data routes and then on the server we skip revalidating when this header is set. When a client-transition is actually made we send a background HEAD (non-blocking) request to the data route without the `purpose: prefetch` header which signals a revalidation should occur if the data is stale. This helps alleviate the number of revalidations occurring currently caused by prefetches as a path can be prefetched but not visited during a session so may not need to be revalidated yet. Fixes: https://github.com/vercel/next.js/issues/17758 x-ref: https://github.com/vercel/next.js/discussions/20521 x-ref: [slack thread](https://vercel.slack.com/archives/C031QM96T0A/p1645129445819139?thread_ts=1645124478.067049&cid=C031QM96T0A)
27 lines
459 B
JavaScript
27 lines
459 B
JavaScript
export default function Page(props) {
|
|
return (
|
|
<>
|
|
<p id="page">blog/[slug]</p>
|
|
<p id="props">{JSON.stringify(props)}</p>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export function getStaticProps({ params }) {
|
|
console.log('revalidating /blog', params.slug)
|
|
return {
|
|
props: {
|
|
params,
|
|
now: Date.now(),
|
|
},
|
|
revalidate: 2,
|
|
}
|
|
}
|
|
|
|
export function getStaticPaths() {
|
|
return {
|
|
paths: ['/blog/first', '/blog/second'],
|
|
fallback: false,
|
|
}
|
|
}
|