Fine Grained Cache Data Revalidation in Server Actions
Unanswered
meow posted this in #help-forum
meowOP
The docs state that revalidateTag gives us "fine grained data caching and revalidation support".
I have a page which is caching two fetch calls successfully and using distinct tags for each fetch. The page also has a server action which revalidatesTag for one of the fetches.
My issue: when I call revalidateTag from my server action, one of the headers sent in the POST is default-no-store which causes the second fetch to SKIP cache.
My desired behaviour: When I call revalidateTag, I would only like 1 of the 2 fetches to be revalidated in the data cache, the 2nd fetch which has a different tag should remain unchanged.
Maybe a server action isn't the right choice for this behaviour, has anyone achieved any such behaviour?
Many thanks!
I have a page which is caching two fetch calls successfully and using distinct tags for each fetch. The page also has a server action which revalidatesTag for one of the fetches.
My issue: when I call revalidateTag from my server action, one of the headers sent in the POST is default-no-store which causes the second fetch to SKIP cache.
My desired behaviour: When I call revalidateTag, I would only like 1 of the 2 fetches to be revalidated in the data cache, the 2nd fetch which has a different tag should remain unchanged.
Maybe a server action isn't the right choice for this behaviour, has anyone achieved any such behaviour?
Many thanks!
2 Replies
meowOP
The code is based on Nextjs server actions example from youtube, here is my code for context! You will need to add a postgres connection string to .env file and change its name to .env so it is processed. I recommend neon for fast setup!