Commit 65db12f
authored
[Segment Cache] Support <Link prefetch={true}> (vercel#74172)
This implements support in the Segment Cache for "full" link prefetches,
typically initiated by passing `prefetch={true}` to a `<Link>`.
The goal of a full prefetch is to request all the data needed for a
navigation, both static and dynamic, so that once the navigation occurs,
the router does not need to fetch any additional data. So, a full
prefetch implicitly instructs the client cache to treat the response as
static, even the dynamic data.
The implementation is largely the same as what we do to support
non-PPR-enabled routes — a request tree is sent to the server describing
which segments are already cached and which ones need to be rendered.
While constructing the request tree, if all the segments are already in
the client cache, the request can be skipped entirely. The main
difference is that a full prefetch will only reuse a cached segment
entry if it does not contain any dynamic holes.1 parent 4c09fa5 commit 65db12f
File tree
6 files changed
+498
-79
lines changed- packages/next/src/client/components
- segment-cache
- test/e2e/app-dir/segment-cache/incremental-opt-in
- app/mixed-fetch-strategies
6 files changed
+498
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
| 287 | + | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
1005 | 1006 | | |
1006 | 1007 | | |
1007 | 1008 | | |
1008 | | - | |
| 1009 | + | |
1009 | 1010 | | |
1010 | 1011 | | |
| 1012 | + | |
1011 | 1013 | | |
1012 | 1014 | | |
1013 | 1015 | | |
1014 | 1016 | | |
1015 | 1017 | | |
1016 | 1018 | | |
1017 | 1019 | | |
1018 | | - | |
1019 | 1020 | | |
1020 | 1021 | | |
1021 | 1022 | | |
1022 | 1023 | | |
1023 | 1024 | | |
1024 | 1025 | | |
1025 | 1026 | | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
1026 | 1034 | | |
1027 | 1035 | | |
1028 | 1036 | | |
| |||
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
14 | | - | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | | - | |
| 29 | + | |
23 | 30 | | |
0 commit comments