mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #734] [CLOSED] feat(prerender): seed KV cache with pre-rendered routes at deploy time #805
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#805
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/734
Author: @raed04
Created: 4/1/2026
Status: ❌ Closed
Base:
main← Head:feat/seed-kv-cache-562📝 Commits (1)
fc51d75feat(prerender): seed KV cache with pre-rendered routes at deploy time📊 Changes
4 files changed (+1024 additions, -1 deletions)
View changed files
📝
packages/vinext/src/cli.ts(+1 -0)➕
packages/vinext/src/cloudflare/seed-kv-cache.ts(+299 -0)📝
packages/vinext/src/deploy.ts(+39 -1)➕
tests/seed-kv-cache.test.ts(+685 -0)📄 Description
Summary
vinext deployso pre-rendered pages are cache HITs from the first requestvinext-prerender.jsonand uploads HTML/RSC entries to Workers KV via the Cloudflare bulk REST APIKVCacheHandler.get():cache:app:<buildId>:<pathname>:htmlHow it works
vinext-prerender.jsonmanifest and pre-rendered HTML/RSC files fromdist/server/prerendered-routes/isrCacheKey()(same function the runtime uses)KVCacheHandlerserialization formatAutomatic when:
CLOUDFLARE_API_TOKENenv var is set andVINEXT_CACHEKV namespace exists in wrangler config.Opt-out:
vinext deploy --no-seed-cacheNon-fatal: Seeding failures log a warning but never block deployment.
Key design decisions
cache:app:<buildId>:<pathname>:htmlmatches whatKVCacheHandler.get()reads at runtime (unlike TPR which usescache:<pathname>— a known pre-existing bug)expiration_ttl— matches runtimeKVCacheHandler.set()behavior (no expiry for static pages)10x revalidateTTL clamped to[60s, 30d]Security
prerenderDirreadFileSync(noexistsSync+readFileSyncrace)success: falseresponses (HTTP 200 with semantic errors)Files
packages/vinext/src/cloudflare/seed-kv-cache.tspackages/vinext/src/deploy.ts--no-seed-cacheflagpackages/vinext/src/cli.tsnoSeedCacheflag to deploy optionstests/seed-kv-cache.test.tsTest plan
isrCacheKey()revalidateAt, noexpiration_ttlrevalidateAt, TTL clamping (min 60s)revalidate=0treated as staticsuccess:falserejectionvp fmt --checkCloses #562
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.