[Prefetching] Move resource hints to tree prefetch (#72367)
Based on:
- #72348
---
When prefetching a segment, the response currently includes all the side
effects (e.g. resource hints and console.logs) for the entire page, not
just the segment being requested. This is mostly the result of
implementation limitations, since React does not currently give us a
good way to extract side effects from an existing Flight response. We
cheat by decoding the original stream inside a new Flight render, which
has the effect of transferring all the side effects from the original
stream onto the new one.
This is mostly fine, except 1) every segment contains the entire page's
resource hints, and 2) we have to decode the original stream once per
segment.
But since all route prefetches must start with a prefetch of the route
tree metadata, we can instead put the hints in that response only. Not
the segment prefetches. That way we only have to decode the original
stream once.
This saves CPU cycles and should result in fewer bytes over the wire,
since we'll only load the resource hints once per page.