forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dynamicIO] Implement a warmup prefetch render in dev (vercel#71278)
To seed caches in dev mode we implemented a prefetch if one had not been done in the recent past. The implementation isn't quite working b/c it doesn't match the prefetch header properly but the mechanics are there. One problem however is the prefetch streams so we end up starting the regular render before the prefetch render is complete. The ideal cache warmup is to only render until there are no more caches to fill in the prefetch. Additionally we can disable certain things like dynamic Request apis and fetches so they stall forever too. This suggests that there is enough of a difference in the needs of the prefetch for cache warming that we ought to implement it as it's own request type. This change implements the mechanics of triggering the warmup prefetch but does not yet implement the changes to things like the request or fetch apis behavior. I will follow up with further changes on top of this commit.
- Loading branch information
Showing
11 changed files
with
322 additions
and
38 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
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
10 changes: 10 additions & 0 deletions
10
test/development/app-dir/dynamic-io-dev-warmup/app/data-fetching.ts
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export async function fetchCached(url: string) { | ||
const response = await fetch(url, { cache: 'force-cache' }) | ||
return response.text() | ||
} | ||
|
||
export async function getCachedData(_key: string) { | ||
'use cache' | ||
await new Promise((r) => setTimeout(r)) | ||
return Math.random() | ||
} |
Oops, something went wrong.