AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Runtime-Rendered Fully Static Pages On PPR Routes Are Not Persisted With .Rsc, Causing Perpetual Cache Misses

When partial prerendering (PPR) is enabled, runtime-rendered pages with no postponed state are written to the file-system cache without an .rsc file, but the read path requires .rsc for such entries, leading to cache MISS on every request after eviction from memory.

highConfidence 95%Next.jsAffected V16.3.4Affected V16.4.0-Canary.19

Origin Analysis

Inconsistent conditions between write and read paths in the file-system cache: FileSystemCache.set() only writes .rsc when !ctx.isRoutePPREnabled, while FileSystemCache.get() expects .rsc for APP_PAGE entries when !ctx.isFallback && (!ctx.isRoutePPREnabled || meta.postponed == null). This asymmetry causes fully static runtime-rendered PPR pages to be treated as cache misses.
1. Create a Next.js app with PPR enabled and a dynamic route /[slug] with generateStaticParams returning ['built'] and cacheComponents: true. 2. Build and start the server with cacheMaxMemorySize: 0 to force file-system cache reads. 3. Request /runtime (not prerendered) multiple times; observe x-nextjs-cache: MISS on every request and no .rsc file written. 4. Apply the proposed one-line fix to FileSystemCache.set() and repeat; observe subsequent requests return HIT and .rsc is written.

Fixing Code Block

Edge Case Audit

This change may write .rsc files for PPR routes that are fully static, which should be safe as the read path already expects them. However, if a partially prerendered page (with postponed state) ever appears with postponed null due to a bug, the .rsc could be written incorrectly. It is recommended to monitor for any unexpected caching of dynamic content. Rollback: revert the condition to the original if regression occurs; the old behavior (no disk read for runtime-rendered static PPR entries) is preferable to serving incorrect cached data.

Ecosystem Topology