[Segment Cache] Fix: Key by rewritten search (#81986)
When a request URL is rewritten, the resulting data must be keyed by its
rewritten search params — the ones that were used by the server to
render the page — not the original search params. This works in most
places by encoding the rewritten search params into page's segment key
in the server response. However, the Segment Cache implementation did
not handle this correctly.
The fix is to read the rewritten search params from the
x-nextjs-rewritten-query header in the server response.
In upcoming PRs, we will use a similar approach for regular route
params, too, so that we can lift the params out of the body of the
server response.
---------
Co-authored-by: Janka Uryga <lolzatu2@gmail.com>