Next.js Discord

Discord Forum

Revalidate Tag

Answered
Korat posted this in #help-forum
Open in Discord
Avatar
KoratOP
If I am using revalidate tag in one of my server actions, even though the fetching of 'let's say users' doesnt have a tag appended, it still requests the RSC which revalidates those data.

Does revalidate tag revalidates the whole cache if the tag isn't found or what because I am a bit confused.
Answered by Arinji
Awesome, mark this as a solution. Btw issues take a whole to be seen by the nextjs team so no need to keep opening the issue.
View full answer

30 Replies

Avatar
So you're saying that your call to revalidateTag() is revalidating other, non-related, non-tagged cache?
Avatar
KoratOP
This is confusing me as well, like:

I have a table of users and a button in the last cell to delete that user, when I delete, i call revalidateTag("whatever") and its recalling the rsc which is returning the fresh data 👀
Avatar
yup this is expected
what would you expect to happen?
Avatar
KoratOP
I just wanna know how it works under the hood, if the tag doesnt exist, does it revalidate the whole cache or?

Because as mentioned Im not adding a tag when calling the fetch
Avatar
if the tag dosent exist, it shouldnt revalidate any cache... no
Avatar
KoratOP
Okay, but I cant explain why calling revalidateTag with a dummy string inside is revalidating the list of users
which is nice
but I dont know how
Avatar
thats not meant to happen
can you show me your data fetching code
Avatar
KoratOP
This is the most basic example
Image
Image
blocking a user shows the isBlocked boolean in the table when invalidateTag is called
Avatar
is it maybe the case that revalidating that tag, is causing something in the stack to re-render?
if you make an example/testing page, and then make a fetch call, tag it, and then revalidate it, you can confirm functionality.
Avatar
KoratOP
But this tag doesn't exist ?
Yeah, that's what I'm thinking but initially I thought even the tag doesn't exists it revalidates everything
Avatar
if you get rid of the revalidate tag call, does it "revalidate everything" still?
may need to see more code to 100% know whats going on.
Avatar
KoratOP
In that case no, I need to hard reload to get the new info
Avatar
and your on dev?
also yea we need code lol
make a minimal reproduction
Avatar
KoratOP
I am on development, Ill try in prod too

The project is big, in that case Ill try a basic repo just to test it out
Avatar
KoratOP
@Arinji I was able to reproduce this in a NextJS 15 fresh app though,

Only these 3 files are needed
Image
Or you still need a codesandbox link ?
Avatar
Make a GitHub issue then since it's clearly a bug
Avatar
KoratOP
Avatar
Awesome, mark this as a solution. Btw issues take a whole to be seen by the nextjs team so no need to keep opening the issue.
Answer