Skip to content

Track vary params for segments without server-side param access#88998

Merged
acdlite merged 1 commit intovercel:canaryfrom
acdlite:vary-params-client-only
Jan 29, 2026
Merged

Track vary params for segments without server-side param access#88998
acdlite merged 1 commit intovercel:canaryfrom
acdlite:vary-params-client-only

Conversation

@acdlite
Copy link
Contributor

@acdlite acdlite commented Jan 25, 2026

Based on:


This implements a partial "vary params" optimization for the segment cache. When a segment doesn't access params on the server, its prefetched data can be reused across different param values.

Two cases are handled:

  1. Segments without a user-provided layout (only loading.tsx or nothing)
  2. Segments with a 'use client' layout

The server now includes a varyParams field in segment prefetch responses. When varyParams is an empty Set, the client re-keys the cache entry with Fallback for all param values, making it reusable across different params.

This is a stepping stone toward full vary params tracking where Server Components would track which specific params they access during rendering.

@nextjs-bot
Copy link
Collaborator

nextjs-bot commented Jan 25, 2026

Tests Passed

@acdlite acdlite force-pushed the vary-params-client-only branch from ea67cdc to 08a3aae Compare January 25, 2026 02:35
@acdlite acdlite marked this pull request as ready for review January 25, 2026 17:42
This implements a partial "vary params" optimization for the segment
cache. When a segment doesn't access params on the server, its
prefetched data can be reused across different param values.

Two cases are handled:
1. Segments without a user-provided layout (only loading.tsx or nothing)
2. Segments with a 'use client' layout

The server now includes a varyParams field in segment prefetch responses.
When varyParams is an empty Set, the client re-keys the cache entry with
Fallback for all param values, making it reusable across different params.

This is a stepping stone toward full vary params tracking where server
components would track which specific params they access during rendering.
@acdlite acdlite force-pushed the vary-params-client-only branch from 08a3aae to 64bca5d Compare January 29, 2026 22:04
@acdlite acdlite merged commit 0e1b6d6 into vercel:canary Jan 29, 2026
10 checks passed
acdlite added a commit that referenced this pull request Jan 29, 2026
Based on:

- #88834
- #88989
- #88998

---

Adds optimistic routing, enabling the client to predict route structure
for URLs that haven't been prefetched yet. When navigating to a URL like
/blog/post-2, if we've previously learned the pattern from /blog/post-1,
we can predict the route structure without waiting for a server
response.

The client learns route patterns from server responses and builds a trie
indexed by URL parts. When a cache miss occurs, we check if the URL
matches a known pattern. If so, we create a synthetic cache entry from
the template, allowing immediate rendering of loading boundaries.

Static siblings (like /blog/featured alongside /blog/[slug]) are tracked
to avoid incorrect predictions — we only predict dynamic routes when
we're confident no static sibling matches.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants