Next.js Discord

Discord Forum

cacheComponents: Would adding cacheTag to child functions/components work?

Unanswered
Azure Gallinule posted this in #help-forum
Open in Discord
Azure GallinuleOP
Let's say I add "use cache" to a page function, then add cacheTag to any component (sync and async) down the tree.

export default async function Page() {
  'use cache'
  return <ChildComponent />
}

function ChildComponent() {
  cacheTag('my-tag')
  return <div>Content</div>
}


Would they revalidate when I call those tags with revalidateTag?

5 Replies

you don't need a "use-cache" at the top of your page function
as long as u mark it as async cacheComponents will do the rest
I also don't think you're supposed to have a cacheTag for a component
@Azure Gallinule