Next.js · Middle · Question 6 of 75
What does the 'use cache' directive do?
- ✓Correct answer: Caches the result of an async function or component; arguments are part of the cache key
- 2Enables caching of all
fetches across the whole app at once and forever - 3Saves a client component's state to the browser's
localStorage
Explanation
'use cache' works with cacheComponents: true: at the level of a data function, a component or a whole file. Arguments and captured values become part of the key. The lifetime is set with cacheLife, invalidation tags with cacheTag. A cached result can become part of the page's static shell.