nextjs - 💡(How to fix) Fix updateTag updates unrelated tags [3 comments, 4 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#85739Fetched 2026-04-08 02:14:03
View on GitHub
Comments
3
Participants
4
Timeline
10
Reactions
3
Author
Timeline (top)
subscribed ×5commented ×3issue_type_added ×1labeled ×1

Code Example

export const timeInAsia = async () => {
  "use cache: remote";
  cacheTag("time-in-asia");
  cacheLife("hours");
  console.log(`Fetching Asia time`);
  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("Asia/Tokyo");

  return now;
};

export const timeInUTC = async () => {
  "use cache";
  cacheTag("time-in-utc");
  cacheLife("hours");
  console.log(`Fetching UTC time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("UTC");

  return now;
};

export const timeInAmerica = async () => {
  "use cache: private";
  cacheTag("time-in-america");
  cacheLife("hours");
  console.log(`Fetching America time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));

  const cookieStore = await cookies();
  console.log(cookieStore.getAll());

  const now = getDateInTimezone("America/New_York");

  return now;
};

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:11:04 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 20.19.4
  npm: 10.8.2
  Yarn: 4.1.1
  pnpm: 10.20.0
Relevant Packages:
  next: 16.0.2-canary.5 // Latest available version is detected (16.0.2-canary.5).
  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/prananta/next-use-cache-private-bug

To Reproduce

  1. npm run build
  2. npm run start
  3. open localhost:3000
  4. click one of the Refresh buttons

Current vs. Expected behavior

According to the doc in https://nextjs.org/docs/app/api-reference/functions/updateTag, updateTag is supposed to update cached data for a specific cache tag. But in my repo, updating certain tag updates other cached data with different tags too. In the repo example, i have three functions that use use cache, use cache: remote and use cache: private respectively. They also have different tags.

export const timeInAsia = async () => {
  "use cache: remote";
  cacheTag("time-in-asia");
  cacheLife("hours");
  console.log(`Fetching Asia time`);
  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("Asia/Tokyo");

  return now;
};

export const timeInUTC = async () => {
  "use cache";
  cacheTag("time-in-utc");
  cacheLife("hours");
  console.log(`Fetching UTC time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));
  const now = getDateInTimezone("UTC");

  return now;
};

export const timeInAmerica = async () => {
  "use cache: private";
  cacheTag("time-in-america");
  cacheLife("hours");
  console.log(`Fetching America time`);

  await new Promise((resolve) => setTimeout(resolve, 1000));

  const cookieStore = await cookies();
  console.log(cookieStore.getAll());

  const now = getDateInTimezone("America/New_York");

  return now;
};

When I called updateTag('time-in-utc') from a server action for example, not only timeInUtc is re-executed, but also timeInAmerica. The updateTag's behavior is unpredictable right now. Sometimes it only updates the cached data for given tag, sometimes it affects other tags too. This happens in both dev and production.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Mon Aug 11 21:11:04 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6031
  Available memory (MB): 36864
  Available CPU cores: 14
Binaries:
  Node: 20.19.4
  npm: 10.8.2
  Yarn: 4.1.1
  pnpm: 10.20.0
Relevant Packages:
  next: 16.0.2-canary.5 // Latest available version is detected (16.0.2-canary.5).
  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)

Vercel (Deployed)

Additional context

I tested using the stable 16 and canary.

extent analysis

TL;DR

The issue with updateTag affecting multiple cache tags may be related to the usage of different cache directives (use cache, use cache: remote, use cache: private) with distinct tags, and a potential inconsistency in how Next.js handles these directives.

Guidance

  • Review the documentation for use cache and its variants to ensure correct usage and understanding of their implications on caching behavior.
  • Verify that the cacheTag function is correctly setting the cache tag for each function, and that these tags are unique and properly scoped.
  • Consider testing with a simplified example to isolate the issue and determine if it's related to the specific cache directives or tags used.
  • Check for any open issues or discussions in the Next.js repository related to caching and updateTag behavior, as this may be a known issue or have a proposed solution.

Notes

The provided information suggests that the issue is not specific to a particular environment or version of Next.js, as it occurs in both development and production, and with different versions of Next.js. However, without further details on the implementation of cacheTag, cacheLife, and updateTag, it's challenging to provide a more specific solution.

Recommendation

Apply workaround: Given the unpredictable behavior of updateTag, it may be necessary to implement a custom caching solution or modify the existing caching logic to better handle the different cache directives and tags. This could involve using a more explicit caching mechanism, such as a library or a custom implementation, to gain better control over cache management.

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 updateTag updates unrelated tags [3 comments, 4 participants]