#revalidateTag invalidates more than it should

1 messages · Page 1 of 1 (latest)

crimson wharf
#

I have a page component using use cache rendering tournament detail

export default async function TournamentPairingsAllPage({ params }: { params: Promise<{ id: string }> }) {
  'use cache';
  const { id } = await params;
  unstable_cacheTag(getTournamentCacheKey(id));
  console.log(`cache miss: all pairings: ${getTournamentCacheKey(id)}`);

  const tournamentResult = await loadTournament(id);
  if (!tournamentResult) {
    return null;
  }

  return <Pairings tournament={tournamentResult} />;
}

and a server action for uploading tournaments that revalidates cache

console.log(`uploading: ${tournamentId}`);
    revalidateTag(getAllTournamentsCacheKey());
    console.log(`revalidated: ${getAllTournamentsCacheKey()}`);
    revalidateTag(getOrganizationTournamentsCacheKey(orgId));
    console.log(`revalidated: ${getOrganizationTournamentsCacheKey(orgId)}`);
    revalidateTag(getTournamentCacheKey(tournamentId));
    console.log(`revalidated: ${getTournamentCacheKey(tournamentId)}`);

I start app, render detail for tournament A and B. I get "cache miss" for both. Reload does not print anything. After calling upload for A which causes revalidate for A, following reloads of A and B print cache miss again. Only A should be reloaded, B should be still cached. Am I missing something?

slim geyserBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

crimson wharf
#

Output from my app to see how cache tags look like:

uploading: 0196ef07-2726-7333-960f-38d5f0e66dd4
revalidated: all_tournaments
revalidated: org_tournaments:org_2vYcFBOC2JkMbSPalnCKdS2L3qw
revalidated: single_tournament:0196ef07-2726-7333-960f-38d5f0e66dd4
cache miss: layout: single_tournament:0196ef07-2726-7333-960f-38d5f0e66dd4
cache miss: my pairings: single_tournament:0196ef07-2726-7333-960f-38d5f0e66dd4
cache miss: layout metadata: single_tournament:0196ef07-2726-7333-960f-38d5f0e66dd4
cache miss: layout: single_tournament:0196fefa-359f-7605-ad87-7b3dc333a6e2
cache miss: roster: single_tournament:0196fefa-359f-7605-ad87-7b3dc333a6e2
cache miss: layout metadata: single_tournament:0196fefa-359f-7605-ad87-7b3dc333a6e2
#

revalidateTag invalidates more than it should

terse drift
#

can you try console.logging what the cache key returns, when you run getTournamentCacheKey, and is it a async function or normal function?

crimson wharf
#

It's sync function. It returns string single_tournament:uuid. See console output one message up.

terse drift
#

use cache is a beta user, its a good idea to open a issue on nextjs github

#

it might be a issue with the code also, but I don't think so

terse drift
#

Github*