The 'use cache' Directive

+15 Mana ✨

The 'use cache' directive is used to cache the result of a function or component. This is part of Next.js's advanced caching mechanisms to improve performance.

When you mark a function or component with 'use cache', its return value is stored and reused for subsequent requests, reducing server load and computation time.

tsx
'use cache'

export async function CachedData() {
  const data = await heavyComputation()
  return <div>{data}</div>
}
✓ Completed