Forward headers from React to static output and dynamic render (#58162)
React can emit a `Link:` header for preloads instead of `<link rel="preload">` in certain scenarios when that can be useful. This works by listening to the `onHeaders` event. In particular it's interesting for PPR because if you have something dynamic outside a Suspense boundary it generates an empty payload without any preloads in it. That's because when we do render the real shell we don't know what the document will look like. However, we can emit the `Link` header for CSS, images and font preloads that we've already discovered. In effect, even a dynamic page gets PPR benefits by early fetching resources. Custom headers is supported for static a ROUTE but not a PAGE. So I had to add similar wiring to forward headers when it's a page being rendered. It's important that this works every where, including dynamic routes, because otherwise we might miss out on preloads that we previously would've had.
Showing
Please
register
or
sign in
to comment