Next.js Discord

Discord Forum

Cache page section

Unanswered
Petit Bleu de Gascogne posted this in #help-forum
Open in Discord
Petit Bleu de GascogneOP
Can i cache a page section (like footer/header/related content) and reuse the cached section on multiple pages?

4 Replies

Petit Bleu de GascogneOP
I have a website using NextJS with "Latest Content" section shared by multiple pages

Is it viable to only query database every 30 seconds to get latest content? but not per page but globally
I don't think you can cache components, but you can add revalidate to your fetch calls: https://nextjs.org/docs/app/building-your-application/data-fetching/revalidating#background-revalidation
if you are not doing a fetch call you can use the new cache function from next, but I need to find the link showing how to use it because its not documented yet :fine: