Next.js · Middle · Question 9 of 75

What is cacheTag('products') inside a cached function for?

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}).

Further reading

Problem with a question

Next.js · Middle · question 9

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz