Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate per-segment prefetch responses #72168

Merged
merged 1 commit into from
Nov 4, 2024

Commits on Nov 4, 2024

  1. 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.
    acdlite committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    80ef83d View commit details
    Browse the repository at this point in the history