-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Segment Cache] Add PPR header to segment prefetch (#73756)
Follow-up to #73715. Since PPR should always result in a cache hit for a prefetch (even in the worst case, there's a fallback cache entry), the only reason a route tree prefetch would not be found in the per-segment cache is because PPR is disabled. So we should just fallthrough to the old prefetching flow whenever PPR is disabled. But the client still needs some way to tell whether the response was served from the per-segment cache or by the old implementation. So I added an explicit response header to every per-segment prefetch. If the header is missing, the client can infer that the route does not support PPR.
- Loading branch information
Showing
5 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
test/e2e/app-dir/segment-cache/incremental-opt-in/app/ppr-disabled/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
import { Suspense } from 'react' | ||
import { connection } from 'next/server' | ||
|
||
async function Content() { | ||
await connection() | ||
return 'Dynamic Content' | ||
} | ||
|
||
export default function PPRDisabled() { | ||
return '(intentionally empty)' | ||
return ( | ||
<Suspense fallback="Loading..."> | ||
<Content /> | ||
</Suspense> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters