Menu

Next.js 16 Cache Components: Where Should You Place 'use cache'?
πŸ“°

Next.js 16 Cache Components: Where Should You Place 'use cache'?

DEV Community: nextjsΒ·PaweΕ‚ SobolewskiΒ·10 days ago
#SYwtpRAj
#devtonextjs#devto#dev#cache#component
Reading 0:00
15s threshold

Next.js 16 ships Cache Components as a first-class caching model: a single 'use cache' directive, paired with cacheLife , that you can drop on a route, a component, or a plain data-fetching function. The pitch is appealing: pick your own granularity, mix static and dynamic content on the same page, and let Partial Prerendering figure out the rest.

That pitch also raises a question the docs don't spend much time on: does it actually matter where you put 'use cache' ? If you wrap an entire component versus just the fetch call inside it, what changes, for the reader and for the server doing the work?

To find out, I built a small dashboard with three crypto price cards (Bitcoin, Ethereum, Solana), all pulling the same kind of data from the same public API, each caching it a different way:

Bitcoin caches the fetch and the render together, at the component level.

Ethereum caches only the fetch; the chart underneath is recomputed on every request.

Solana caches nothing at all.

All three run under the exact…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.