Skip to content

[nextjs-tracker] Cache Components: deduplicate background revalidation for stale entries #3228

Description

@ask-bonk

Next.js Change

Commit: ac55fd9
PR: #98446

What changed

Next.js now tracks background revalidation work independently for each 'use cache' lookup key. Requests that observe a stale entry return that stale value while an existing regeneration and its cache writes complete; they neither wait for that work nor start a duplicate regeneration. The task is registered before generation begins and remains registered through cache persistence, including slow handler reads and writes.

Impact on vinext

Vinext implements 'use cache' and stale-while-revalidate caching. Its revalidation deduplication must cover background work through persistence, not only generation, or concurrent stale reads can invoke cache functions multiple times and cause duplicate side effects.

Acceptance criteria

  • Track in-flight background revalidations by the resolved cache lookup key.
  • Register the task before it can begin generation and remove it only after generation, stream cleanup, and cache writes settle.
  • Serve the existing stale entry immediately while matching background work is in flight.
  • Avoid a second regeneration when a slow cache read returns an entry that was stale at lookup start.
  • Preserve independent revalidation for distinct root-parameter-specific keys.
  • Add focused regression coverage for concurrent stale reads, tag revalidation, slow reads, and slow cache writes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    nextjs-trackingTracking issue for a Next.js canary change relevant to vinext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions