#use cache invalidateTags only impact domain, not global

1 messages · Page 1 of 1 (latest)

lone shale
#

I'm using use cache on a route, but it only caches the domain and when using invalidateTags from a different domain, it doesnt do anything

flint riverBOT
#

Hi @lone shale. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the knowledge sources, it appears that your observation about cache invalidation being domain-specific is correct. This behavior is by design in Next.js and Vercel's implementation of caching and revalidation.

According to the Vercel documentation on Incremental Static Regeneration (ISR):

"On-demand revalidation is scoped to the domain and deployment where it occurs, and doesn't affect sub domains or other deployments."

This means that when you use revalidateTag or similar methods to invalidate cache, it only affects the specific domain where the revalidation is triggered. This is a limitation of the current implementation, especially in multi-tenant or multi-domain setups.

To work around this limitation in a multi-tenant project, you might consider:

  1. Using a more generic tag that applies across all domains.
  2. Implementing a custom solution to trigger revalidation for all relevant domains when needed.
  3. Using revalidatePath instead of revalidateTag, although this might have broader effects than desired.

If you need to revalidate across domains, you may want to check the Vercel documentation for potential solutions or consider reaching out to Vercel support for more specific guidance on your use case.

It's worth noting that this behavior is intentional for security and isolation reasons, but it can indeed be challenging in multi-tenant scenarios.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: