Skip to content

Redirects drop _rsc & lead to dirty cache in Chrome #79346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lujjjh opened this issue May 18, 2025 · 1 comment · May be fixed by #79363
Open

Redirects drop _rsc & lead to dirty cache in Chrome #79346

lujjjh opened this issue May 18, 2025 · 1 comment · May be fixed by #79363
Labels
Headers Related to the async headers() function. linear: next Confirmed issue that is tracked by the Next.js team.

Comments

@lujjjh
Copy link

lujjjh commented May 18, 2025

Link to the code that reproduces this issue

https://github.com/lujjjh/nextjs-rsc-dirty-cache-repro

To Reproduce

  1. Open https://nextjs-rsc-dirty-cache-repro.vercel.app in Chrome
  2. Close the tab
  3. Reopen closed tab using ctrl / cmd + T

Current vs. Expected behavior

Current behavior: The RSC response (text/x-component) is shown.

Current behavior

Expected behavior: The page content (HTML) is shown.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Tue, 29 Apr 2025 09:23:13 +0000
  Available memory (MB): 32083
  Available CPU cores: 16
Binaries:
  Node: 23.9.0
  npm: 11.3.0
  Yarn: N/A
  pnpm: 10.10.0
Relevant Packages:
  next: 15.3.2 // Latest available version is detected (15.3.2).
  eslint-config-next: 15.3.2
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Chrome: Version 136.0.7103.114 (Official Build) (arm64)

Which area(s) are affected? (Select all that apply)

Headers

Which stage(s) are affected? (Select all that apply)

next start (local), Vercel (Deployed), Other (Deployed)

Additional context

  1. The prefetch request to https://nextjs-rsc-dirty-cache-repro.vercel.app/en?_rsc=xxxx is redirected to / by the middleware. However, the _rsc query parameter is not visible to the middleware, so it gets dropped during the redirect — which results in the RSC response being cached by Chrome under /.
  2. Maybe _rsc should be preserved while redirecting?
  3. I believe that including Rsc in the Vary response header should resolve this issue, although I haven’t verified it yet.
  4. When running under next start (self-hosted), the Cache-Control header is set to s-maxage=31536000 with no max-age or no-cache directives—unlike Vercel’s defaults. Is this intentional?

Related with #65783, #65787, #76925.

@github-actions github-actions bot added the Headers Related to the async headers() function. label May 18, 2025
@lujjjh lujjjh changed the title 307 redirect drops _rsc & leads to dirty cache in Chrome Redirects drop _rsc & lead to dirty cache in Chrome May 18, 2025
@abhi12299 abhi12299 linked a pull request May 19, 2025 that will close this issue
@adhhamsafwan
Copy link

Same issue on Development and Production. Must be fixed soon.

@ztanner ztanner added the linear: next Confirmed issue that is tracked by the Next.js team. label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Headers Related to the async headers() function. linear: next Confirmed issue that is tracked by the Next.js team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants