Fix route cache keying for unprefetched navigations (#90400)
When navigating to a route that wasn't previously prefetched (e.g. via a
Link with prefetch={false}, or router.push()), the client stores the
route data from the server response in the cache so it can be reused by
future navigations and prefetches to the same URL.
These entries were being stored with a null "nextUrl" cache key, but
lookups use the real nextUrl from router state, so every subsequent
lookup missed. This caused redundant requests for route data the client
already had.
The fix threads the nextUrl through the route discovery path so it
reaches the cache write with the correct value. For non-intercepted
routes the entry is keyed with a wildcard (reusable regardless of
nextUrl); for intercepted routes it uses the specific nextUrl, since the
route structure varies by referrer.
Also cleans up how interception routes interact with the optimistic
route matching system: patterns are now always stored during discovery
(previously they were skipped), and the interception bailout happens in
a single place during matching rather than being duplicated across
multiple check sites.
Closes #88863
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
Co-authored-by: Hamidreza Hanafi <hamidreza.hanafi@faire.com>
---------
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
Co-authored-by: Hamidreza Hanafi <hamidreza.hanafi@faire.com>