[PR #645] [MERGED] feat: seed memory cache from pre-rendered routes #741

Closed
opened 2026-05-06 13:09:54 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/645
Author: @NathanDrake2406
Created: 3/22/2026
Status: Merged
Merged: 3/23/2026
Merged by: @james-elicx

Base: mainHead: feat/seed-memory-cache-from-prerender


📝 Commits (2)

  • 5d9340c feat: seed memory cache from pre-rendered routes at startup
  • 2b744d3 fix: address review feedback on cache seeding PR

📊 Changes

5 files changed (+696 additions, -7 deletions)

View changed files

📝 packages/vinext/src/build/prerender.ts (+31 -6)
📝 packages/vinext/src/build/run-prerender.ts (+4 -1)
📝 packages/vinext/src/server/prod-server.ts (+10 -0)
packages/vinext/src/server/seed-cache.ts (+183 -0)
tests/seed-cache.test.ts (+468 -0)

📄 Description

Summary

  • Reads vinext-prerender.json at production server startup and populates the MemoryCacheHandler with pre-rendered HTML/RSC files from dist/server/prerendered-routes/
  • First request to any pre-rendered page is now a cache HIT instead of a full re-render
  • Adds buildId, router, and trailingSlash to the prerender manifest so the seeding function can construct matching cache keys and locate files correctly

Changes

File Change
src/server/seed-cache.ts New seedMemoryCacheFromPrerender() function
src/build/prerender.ts Add router to PrerenderRouteResult, add buildId/trailingSlash to manifest
src/build/run-prerender.ts Pass buildId/trailingSlash to writePrerenderIndex
src/server/prod-server.ts Call seeding at App Router production server startup
tests/seed-cache.test.ts 11 unit tests

Scope

App Router only for now. Pages Router seeding requires the prerender phase to also write pageData JSON files (not currently done), so it's left for a follow-up.

Closes #561

Test plan

  • 11 unit tests covering: ISR routes, static routes, dynamic routes, index route, trailingSlash layout, skipped/errored routes, missing manifest, missing HTML files, missing RSC files, multiple routes
  • Existing prerender tests (46) and ISR cache tests (42) pass unchanged
  • Type-aware lint clean

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/645 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/22/2026 **Status:** ✅ Merged **Merged:** 3/23/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `feat/seed-memory-cache-from-prerender` --- ### 📝 Commits (2) - [`5d9340c`](https://github.com/cloudflare/vinext/commit/5d9340cce0ea5482be708a211718b633d872bfa6) feat: seed memory cache from pre-rendered routes at startup - [`2b744d3`](https://github.com/cloudflare/vinext/commit/2b744d3c1b0a993a0dacc9248cb834ffedd55f6f) fix: address review feedback on cache seeding PR ### 📊 Changes **5 files changed** (+696 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/build/prerender.ts` (+31 -6) 📝 `packages/vinext/src/build/run-prerender.ts` (+4 -1) 📝 `packages/vinext/src/server/prod-server.ts` (+10 -0) ➕ `packages/vinext/src/server/seed-cache.ts` (+183 -0) ➕ `tests/seed-cache.test.ts` (+468 -0) </details> ### 📄 Description ## Summary - Reads `vinext-prerender.json` at production server startup and populates the `MemoryCacheHandler` with pre-rendered HTML/RSC files from `dist/server/prerendered-routes/` - First request to any pre-rendered page is now a cache HIT instead of a full re-render - Adds `buildId`, `router`, and `trailingSlash` to the prerender manifest so the seeding function can construct matching cache keys and locate files correctly ## Changes | File | Change | |------|--------| | `src/server/seed-cache.ts` | New `seedMemoryCacheFromPrerender()` function | | `src/build/prerender.ts` | Add `router` to `PrerenderRouteResult`, add `buildId`/`trailingSlash` to manifest | | `src/build/run-prerender.ts` | Pass `buildId`/`trailingSlash` to `writePrerenderIndex` | | `src/server/prod-server.ts` | Call seeding at App Router production server startup | | `tests/seed-cache.test.ts` | 11 unit tests | ## Scope App Router only for now. Pages Router seeding requires the prerender phase to also write `pageData` JSON files (not currently done), so it's left for a follow-up. Closes #561 ## Test plan - [x] 11 unit tests covering: ISR routes, static routes, dynamic routes, index route, trailingSlash layout, skipped/errored routes, missing manifest, missing HTML files, missing RSC files, multiple routes - [x] Existing prerender tests (46) and ISR cache tests (42) pass unchanged - [x] Type-aware lint clean --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:09:54 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#741
No description provided.