mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
If we're reasonably confident that a segment can be prefetched statically without omitting data that would have been included during a runtime prefetch (e.g. cookies), the client should attempt prefetch the segment statically instead of going straight to a runtime request. The decision for whether to do this is based on the ShouldAttemptStaticPrefetch added in previous steps. If it turns out the static response is not sufficient, then it will fall back to a runtime request. This makes prefetching cheaper for pages that are fully statically renderable. We can make the optimization better in the future with more reliable per-segment computation of the ShouldAttemptStaticPrefetch, but the current approach should at least work for fully static pages, which is what's most important. This optimization applies during both the Shell phase and the Speculative phase of the prefetching algorithm.
18 lines
692 B
TypeScript
18 lines
692 B
TypeScript
// A page that accesses no runtime data at all: no cookies, headers,
|
|
// searchParams, params, or `connection()`. Every prerender of this route is
|
|
// clean, so its route tree prefetch always carries the static-prefetch hint,
|
|
// and the static per-segment responses are always complete (a runtime
|
|
// request would return nothing more).
|
|
//
|
|
// Note the Shell phase is always permitted to issue a runtime shell request,
|
|
// so the absence of one in the test is attributable to the static shell
|
|
// attempt succeeding, not to configuration forbidding runtime requests.
|
|
|
|
export default function Page() {
|
|
return (
|
|
<main>
|
|
<p id="page-content">Fully static page content</p>
|
|
</main>
|
|
)
|
|
}
|