'use cache' — Next.js 16 Directive

Cached with explicit tags and infinite lifetime. Only invalidated on-demand.

Page Info

Rendering Strategy
'use cache' + cacheTag() + cacheLife()
Cached At
2026-11-20T23:07:19.386Z
Cache Tags
use-cache-demodemo-data
Cache Lifetime
Infinite (stale: ∞, revalidate: ∞, expire: ∞)
Fetched Post
eum et est occaecati

How it works

  • • Function uses 'use cache' directive
  • • cacheTag('use-cache-demo', 'demo-data') sets explicit tags
  • • cacheLife({ stale: Infinity, ... }) — never expires on its own
  • • The "Cached At" timestamp stays the same until you revalidate
  • • Tags flow through two handlers: use-cache (timestamps) + legacy (CDN purge)
  • • Calling revalidateTag('use-cache-demo') invalidates both + clears CDN

Test invalidation

Go to /cache-test and revalidate tag use-cache-demo. Then refresh this page — the "Cached At" timestamp should update.

Check headers: curl -sI /demos/use-cache. The x-next-cache-tags header should includeuse-cache-demo and demo-data.