Dynamic page incorrectly treated as static when query parameters are added – RSC payload not fetched on re-entry (prefetch via <Link>)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/github/Donggggg/nextjs-router-cache-test-app/main
To Reproduce
1.Visit a dynamic page (e.g., /posts/[id]).
→ RSC payload is fetched as expected.
- Navigate to the same page with a query parameter (e.g., /posts/[id]?tab=recent).
- back
- Visit same page using with prefetch
→ No RSC payload request is sent over the network. It appears to reuse a cached payload from the Router Cache.
However, if I start from the plain /posts/[id] page (without any query) or /posts/[id]?tab=recent (already have query) and re-enter it again via client navigation, the RSC payload is fetched every time as expected.
So this behavior only happens after a query parameter was added.
Current vs. Expected behavior
Because the page is declared dynamic (revalidate = 0), adding query parameters should not make it static or cached by the Router Cache.
Each navigation should trigger a fresh RSC payload request.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.2.0: Fri Dec 6 18:51:28 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T8112
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.17.0
npm: 10.9.2
Yarn: 4.5.0
pnpm: 10.7.0
Relevant Packages:
next: 15.5.6
eslint-config-next: N/A
react: 19.2.0
react-dom: 19.2.0
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Dynamic Routes
Which stage(s) are affected? (Select all that apply)
Other (Deployed), next start (local)
Additional context
When I set the following experimental config:
experimental: {
staleTimes: {
dynamic: 0,
static: 0,
},
},
…the RSC payload is fetched on every navigation as expected (no cache reuse).
That suggests the page was being mistakenly treated as static once query params were added, and the Router Cache then reused it on re-entry.
Additionally, when I disabled prefetch by setting prefetch={false} on the <Link> component and tested the same navigation scenario, the RSC payload was correctly requested again.
This indicates that the issue only occurs when the navigation is prefetched and subsequently cached by the Router Cache.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and run it with next start, following the navigation sequence involving a dynamic route, query parameters, back navigation, and a prefetched Link. Compare Router Cache behavior with staleTimes set to zero and with prefetch disabled. Done means re-entry through a prefetched Link sends a fresh RSC payload for the dynamic page with query parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- next.js, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100