Skip to content
Discussion options

You must be logged in to vote

1. Where to place use cache:

Place it as close to the data fetching as possible — ideally at the individual component or function level, not the layout. This gives you granular control. Example:

async function ProductList() {
  'use cache'
  cacheLife('hours')
  const data = await fetch('https://api.example.com/products')
  return <List items={data.json()} />
}

You can add it at the page or layout level, but that caches everything — which is rarely what you want with external APIs.

2. use cache + PPR:

They work great together. PPR splits your page into a static shell and dynamic parts. Use use cache on the cacheable parts, and wrap truly dynamic parts (user-specific data) in <Suspense>. T…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by JohnHarryson94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants