mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Removes the "allow-runtime" prefetch config, and turns its behavior on implicitly wherever Partial Prefetching is enabled. The original motivation for "allow-runtime" was to give apps more control over server costs triggered by prefetches. Until a route explicitly opts in, prefetches would only be served from the CDN, not from the server. The problem, though, was it was very confusing to know when to add or remove this configuration. The incentive for many apps was to add it everywhere, with no clear signal for when to remove it. Our updated thinking is that Partial Prefetching itself already provides sufficient protection against runaway prefetching costs: per-link prefetches only happen on Link components that explicitly opt in with the prefetch prop. The optimizations landed earlier in this stack also make allow-runtime less necessary: on pages where all the content is statically renderable, prefetches are served from the static cache and no runtime request is ever issued; only a page that accesses non-static data is prefetched at runtime. The upshot of this decision is that runtime versus static becomes an internal optimization; the same content gets prefetched regardless of whether or how Next.js is able to optimize it.
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { LinkAccordion } from '../components/link-accordion'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<main>
|
|
<h1>Home</h1>
|
|
<p>
|
|
Each link below points to a route that exercises a different combination
|
|
of the static-prefetch hint on the route tree and the per-segment
|
|
sufficiency signal. The links are hidden behind LinkAccordion checkboxes
|
|
so the tests control exactly when each prefetch fires.
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<LinkAccordion href="/fully-static">Fully static</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/uses-cookies">Uses cookies</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/uses-search-params?q=test">
|
|
Uses search params
|
|
</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/uses-connection">Uses connection</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/dynamic-param/one">
|
|
Dynamic param one
|
|
</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/dynamic-param/two">
|
|
Dynamic param two
|
|
</LinkAccordion>
|
|
</li>
|
|
{/* The speculative-* routes are partial (non-eager), so their
|
|
links use prefetch={true} to opt into the Speculative phase —
|
|
otherwise only their App Shell would be prefetched. */}
|
|
<li>
|
|
<LinkAccordion href="/speculative-static" prefetch={true}>
|
|
Speculative static
|
|
</LinkAccordion>
|
|
</li>
|
|
<li>
|
|
<LinkAccordion href="/speculative-cookies" prefetch={true}>
|
|
Speculative cookies
|
|
</LinkAccordion>
|
|
</li>
|
|
</ul>
|
|
</main>
|
|
)
|
|
}
|