#revalidateTag issue
1 messages · Page 1 of 1 (latest)
Based on the information provided in the extracts, it seems that there have been some issues reported with the revalidateTag function in Next.js. Some users have reported unpredictable behavior when revalidating multiple tags, with only the last tag being revalidated in some cases.
The revalidateTag function is used to purge cached data on-demand for a specific cache tag. It's important to note that revalidateTag only invalidates the cache when the path is next visited. This means calling revalidateTag with a dynamic route segment will not immediately trigger many revalidations at once. The invalidation only happens when the path is next visited.
Here is an example of how to use revalidateTag:
import { revalidateTag } from 'next/cache'
export default async function submit() {
await addPost()
revalidateTag('posts')
}
In this example, the revalidateTag function is called with the tag 'posts' after a new post is added. This will invalidate the cache for 'posts' the next time the path is visited.
If you're experiencing issues with revalidateTag, it's recommended to ensure you're using the latest version of Next.js. If the issue persists, consider opening a new issue with a minimal reproduction for further investigation.
Sources:
- Next.js Documentation (https://nextjs.org/docs/app/api-reference/functions/revalidateTag)
- Github Issue 55960 (https://github.com/vercel/next.js/issues/55960)
- Github Issue 49509 (https://github.com/vercel/next.js/issues/49509)
- Github Issue 52020 (https://github.com/vercel/next.js/issues/52020)
- Github Issue 53117 (https://github.com/vercel/next.js/issues/53117)