nextjs - 💡(How to fix) Fix revalidateTag not using stale-while-revalidate [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85780Fetched 2026-04-08 02:13:58
View on GitHub
Comments
3
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×3issue_type_added ×1

Code Example

Operating System:
  Platform: linux
  Arch: x64
  Version: #35~22.04.1-Ubuntu SMP Mon May 26 18:08:30 UTC 2025
  Available memory (MB): 7945
  Available CPU cores: 2
Binaries:
  Node: 22.17.0
  npm: 9.8.1
  Yarn: 1.22.22
  pnpm: 10.13.1
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/matthewca/revalidatetag-swr-issue

To Reproduce

  1. npm run build
  2. npm run start
  3. open localhost:3000/en/demo
  4. POST to localhost:3000/api/demo/clear
  5. refresh localhost:3000/en/demo

Current vs. Expected behavior

After revalidating the tag and refreshing the demo page, I expected to see the stale data instantly.

Instead, the page seems to wait until the new data is received before displaying the old stale data in the component. Refreshing once more reveals the new data.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #35~22.04.1-Ubuntu SMP Mon May 26 18:08:30 UTC 2025
  Available memory (MB): 7945
  Available CPU cores: 2
Binaries:
  Node: 22.17.0
  npm: 9.8.1
  Yarn: 1.22.22
  pnpm: 10.13.1
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

cacheComponents

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

next build (local)

Additional context

No response

extent analysis

TL;DR

  • The issue can likely be resolved by adjusting the caching strategy for the revalidate tag in the Next.js configuration to ensure immediate revalidation and display of stale data.

Guidance

  • Review the revalidate tag configuration in the Next.js setup to ensure it is correctly set up to revalidate data on refresh.
  • Verify that the getStaticProps or getServerSideProps methods are correctly implemented to handle stale data and revalidation.
  • Check the caching headers and configuration for the /api/demo/clear endpoint to ensure it is not interfering with the revalidation process.
  • Consider adding logging or debugging statements to track the data flow and revalidation process to better understand the issue.

Example

No specific code example can be provided without more details on the implementation, but reviewing the revalidate tag configuration and the data fetching methods in the provided GitHub repository code may help identify the issue.

Notes

The exact solution may depend on the specific implementation details of the revalidate tag and the data fetching mechanisms used in the application, which are not fully provided in the issue description.

Recommendation

  • Apply workaround: Adjust the caching strategy for the revalidate tag to ensure immediate revalidation and display of stale data, as this seems to be the most direct approach to resolving the described behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix revalidateTag not using stale-while-revalidate [3 comments, 2 participants]