Skip to content

isr: namespace cache keys by buildId or deploy version #415

@Divkix

Description

@Divkix

Problem

ISR cache keys are currently formatted as <router>:<pathname> (e.g., pages:/about). When a new version of the app is deployed, the old cached entries may be served because the cache key hasn't changed. This can cause stale content from a previous build to be served to users.

Proposed Solution

Include buildId in the ISR cache key format: <router>:<buildId>:<pathname>.

The buildId is already available at runtime via process.env.__VINEXT_BUILD_ID (injected by the Vite define plugin). The change is to pass it through to isrCacheKey() and include it in the generated key.

This ensures that each deployment gets its own cache namespace, preventing stale cache reuse across deploys.

Acceptance Criteria

  • isrCacheKey() accepts optional buildId parameter
  • When buildId is provided, key format is <router>:<buildId>:<pathname>
  • Without buildId, format is unchanged (backward compat)
  • Long paths with buildId still hash correctly when exceeding length limit
  • All callers updated: dev-server.ts, pages-server-entry.ts
  • Tests cover all cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions