Unverified Commit e7b58935 authored by Andrew Clark's avatar Andrew Clark Committed by GitHub

Remove PPR feature check from Segment Cache client (#74669)

Follow-up to #73960. We should no longer check if PPR is enabled when
determining whether to use the Segment Cache or the old client cache.
parent 1f4fa25f
......@@ -275,30 +275,29 @@ function Router({
const routerInstance: AppRouterInstance = {
back: () => window.history.back(),
forward: () => window.history.forward(),
prefetch:
process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE
? // 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 an action.
(href) =>
prefetchWithSegmentCache(
href,
actionQueue.state.nextUrl,
actionQueue.state.tree
)
: (href, options) => {
// Use the old prefetch implementation.
const url = createPrefetchURL(href)
if (url !== null) {
startTransition(() => {
dispatch({
type: ACTION_PREFETCH,
url,
kind: options?.kind ?? PrefetchKind.FULL,
})
prefetch: process.env.__NEXT_CLIENT_SEGMENT_CACHE
? // 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 an action.
(href) =>
prefetchWithSegmentCache(
href,
actionQueue.state.nextUrl,
actionQueue.state.tree
)
: (href, options) => {
// Use the old prefetch implementation.
const url = createPrefetchURL(href)
if (url !== null) {
startTransition(() => {
dispatch({
type: ACTION_PREFETCH,
url,
kind: options?.kind ?? PrefetchKind.FULL,
})
}
},
})
}
},
replace: (href, options = {}) => {
startTransition(() => {
navigate(href, 'replace', options.scroll ?? true)
......
......@@ -173,7 +173,7 @@ export function navigateReducer(
return handleExternalUrl(state, mutable, href, pendingPush)
}
if (process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
if (process.env.__NEXT_CLIENT_SEGMENT_CACHE) {
// (Very Early Experimental Feature) Segment Cache
//
// Bypass the normal prefetch cache and use the new per-segment cache
......
......@@ -11,10 +11,9 @@ import {
export const prefetchQueue = new PromiseQueue(5)
export const prefetchReducer =
process.env.__NEXT_PPR && process.env.__NEXT_CLIENT_SEGMENT_CACHE
? identityReducerWhenSegmentCacheIsEnabled
: prefetchReducerImpl
export const prefetchReducer = process.env.__NEXT_CLIENT_SEGMENT_CACHE
? identityReducerWhenSegmentCacheIsEnabled
: prefetchReducerImpl
function identityReducerWhenSegmentCacheIsEnabled<T>(state: T): T {
// Unlike the old implementation, the Segment Cache doesn't store its data in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment