next.js
65e39a3e - Add Segment Cache feature check to `prefetch` API (#72861)

Commit
1 year ago
Add Segment Cache feature check to `prefetch` API (#72861) Wraps the `prefetch` API in a feature check for the Segment Cache, and forwards the call to a stub for the new implementation. Unlike the old implementation, the Segment Cache doesn't store its data in the router reducer state; it writes into a global mutable cache. So we don't need to dispatch a router action. Since the Segment Cache isn't actually implemented yet, this effectively disables prefetching when the experimental flag is enabled. There's some validation that we do for prefetch URLs that I extracted into a shared function. (For example, we only prefetch same-origin URLs, and we don't prefetch anything in development.)
Author
Parents
Loading