Next.js · Middle · Question 9 of 75
What is cacheTag('products') inside a cached function for?
- ✓Correct answer: To invalidate entries with this tag later
- 2To send the tag in a response header for CDN caching
- 3To limit the cache to the
/productsroute only
Explanation
Tags link cache entries to a type of data rather than a URL. One product mutation can invalidate every page and component that uses products: revalidateTag('products', 'max'). You can set several tags, e.g. a general one and one with an id: cacheTag('products', product-${id}).