mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
This adds support for caching `fetch` responses in server components across HMR refresh requests. The two main benefits are faster responses for those requests, and reduced costs for billed API calls during local development. **Implementation notes:** - The feature is guarded by the new experimental flag `serverComponentsHmrCache`. - The server components HMR cache is intentionally independent from the incremental cache. - Fetched responses are written to the cache after every original fetch call, regardless of the cache settings (specifically including `no-store`). - Cached responses are read from the cache only for HMR refresh requests, potentially also short-cutting the incremental cache. - The HMR refresh requests are marked by the client with the newly introduced `Next-HMR-Refresh` header. - I shied away from further extending `renderOpts`. The alternative of adding another parameter to `renderToHTMLOrFlight` might not necessarily be better though. - This includes a refactoring to steer away from the "fast refresh" wording, since this is a separate (but related) [React feature](https://github.com/facebook/react/issues/16604#issuecomment-528663101) (also build on top of HMR). x-ref: #48481
16 lines
241 B
TypeScript
16 lines
241 B
TypeScript
import Link from 'next/link'
|
|
import React from 'react'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<>
|
|
<p>
|
|
<Link href="/edge">edge</Link>
|
|
</p>
|
|
<p>
|
|
<Link href="/node">node</Link>
|
|
</p>
|
|
</>
|
|
)
|
|
}
|