forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate per-segment prefetch responses
Follow up to vercel#71113. This generates a prefetch response for route segments, so the client can request them individually, and reuse shared layouts between separate page prefetches. Since this is exclusive to PPR, segment prefetches are always static and do not reach the application layer. They are served directly from cache. (This part was implemented in the previous PR.) The prerendered segment data is generated (and revalidated) simultaneously with the prerender of the entire page, to ensure consistency between parent and child segments. Since we always rebuild the whole page, we can save an extra render of each segment by reusing the Flight response that was used to generate the initial HTML. We do this by decoding the page data using a server-side Flight consumer, picking out an individual segment's data, then re-encoding it as its own Flight response. We have to do this once per segment — not ideal, but for now it's the only way to make sure the side effects from the original Flight stream (e.g. Float preloads) are transferred to the per-segment streams. This PR does not yet include any updates to the client router.
- Loading branch information
Showing
4 changed files
with
439 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.