mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #405] [MERGED] feat: ISR caching for App Router (production-only, stale-while-revalidate) #547
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#547
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/405
Author: @james-elicx
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/10/2026
Merged by: @james-elicx
Base:
main← Head:opencode/happy-knight📝 Commits (10+)
fe46ae6feat: add ISR caching for App Router (production-only, stale-while-revalidate)975da3bfix: remove unused isrCachePath variable and fix formattingdaf73b3fix: cache RSC wire format (rscData) in ISR entries; serve RSC requests from cache695c49afix(isr): fix RSC cache miss and early-exit performance for App Router ISR73a44c0feat(isr): cache RSC prefetch responses immediately as partial entriesff8e08afix(isr): use ALS to thread ExecutionContext into KVCacheHandler without constructor argb933772fix(isr): store activeHandler on globalThis to fix cross-environment cache isolationf3a5005fix(isr): allow force-static/error pages to be served from ISR cache, prevent partial RSC write from clobbering complete entry46fbef1fix(isr): split HTML and RSC into separate cache keys, eliminating write races2d1259cfix(kv-cache): always use 30-day KV TTL regardless of revalidate frequency📊 Changes
10 files changed (+3068 additions, -135 deletions)
View changed files
📝
packages/vinext/src/cloudflare/kv-cache-handler.ts(+21 -12)📝
packages/vinext/src/deploy.ts(+21 -5)📝
packages/vinext/src/entries/app-rsc-entry.ts(+391 -15)📝
packages/vinext/src/index.ts(+2 -0)📝
packages/vinext/src/shims/cache.ts(+31 -8)📝
tests/__snapshots__/entry-templates.test.ts.snap(+2328 -90)📝
tests/app-router.test.ts(+173 -1)📝
tests/deploy.test.ts(+17 -1)📝
tests/features.test.ts(+78 -1)📝
tests/shims.test.ts(+6 -2)📄 Description
Summary
Adds ISR (Incremental Static Regeneration) caching to the App Router, matching Next.js stale-while-revalidate semantics on Cloudflare Workers.
Cache behaviour
Implementation
ISR helpers are inlined as generated JS inside the virtual RSC entry (same pattern as Pages Router in `pages-server-entry.ts`):
Tests
`tests/features.test.ts` — `ISR (App Router)` suite:
`tests/app-router.test.ts` — `generateRscEntry ISR code generation` suite (13 tests):
`tests/kv-cache-handler.test.ts`: TTL is always 30 days (documented rationale for flat TTL vs 10× revalidate)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.