From f61f5aba9e35464e9ae6ede68abbf4ed9e5090b1 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Sun, 15 Dec 2024 01:06:10 -0500 Subject: [PATCH] Generate per-segment responses for any static page Originally I gated per-segment prefetch generation on the PPR flag, because I thought the client Segment Cache would require PPR to be enabled on the server. However, since then the strategy has evolved and I do think we can roll out the Segment Cache independently of PPR. Dynamic pages without PPR won't be able to take full advantage of the Segment Cache, but if the page is fully static then there's no reason we can't implement all the same behavior. So during per-segment prerendering, I've changed the feature condition to check for the `clientSegmentCache` flag instead of the PPR one. --- packages/next/src/server/app-render/app-render.tsx | 5 +---- packages/next/src/server/app-render/types.ts | 1 + packages/next/src/server/base-server.ts | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/next/src/server/app-render/app-render.tsx b/packages/next/src/server/app-render/app-render.tsx index 523116e96fbfb3..eafc76c18e946e 100644 --- a/packages/next/src/server/app-render/app-render.tsx +++ b/packages/next/src/server/app-render/app-render.tsx @@ -3979,10 +3979,7 @@ async function collectSegmentData( // decomposed into a separate stream per segment. const clientReferenceManifest = renderOpts.clientReferenceManifest - if ( - !clientReferenceManifest || - renderOpts.experimental.isRoutePPREnabled !== true - ) { + if (!clientReferenceManifest || !renderOpts.experimental.clientSegmentCache) { return } diff --git a/packages/next/src/server/app-render/types.ts b/packages/next/src/server/app-render/types.ts index 9b5de5151e4fac..e77aa229395262 100644 --- a/packages/next/src/server/app-render/types.ts +++ b/packages/next/src/server/app-render/types.ts @@ -183,6 +183,7 @@ export interface RenderOptsPartial { expireTime: ExpireTime | undefined clientTraceMetadata: string[] | undefined dynamicIO: boolean + clientSegmentCache: boolean inlineCss: boolean authInterrupts: boolean } diff --git a/packages/next/src/server/base-server.ts b/packages/next/src/server/base-server.ts index cd604095281a81..3c23f8af115226 100644 --- a/packages/next/src/server/base-server.ts +++ b/packages/next/src/server/base-server.ts @@ -592,6 +592,8 @@ export default abstract class Server< expireTime: this.nextConfig.expireTime, clientTraceMetadata: this.nextConfig.experimental.clientTraceMetadata, dynamicIO: this.nextConfig.experimental.dynamicIO ?? false, + clientSegmentCache: + this.nextConfig.experimental.clientSegmentCache ?? false, inlineCss: this.nextConfig.experimental.inlineCss ?? false, authInterrupts: !!this.nextConfig.experimental.authInterrupts, },