Next.js Discord

Discord Forum

Cache Part of Data

Unanswered
alfon posted this in #help-forum
Open in Discord
Is there a way to fetch and cache the resulting object into multiple caches?
In my case, there is a fetcher in page.tsx that also fetch the same data required in parent layout.tsx.
Is there a way to do this without duplicating the fetches?

2 Replies

I tried putting 'cache' object outside server component but it is persisted in between client side routing (?) I thought it would be cleared per client side navigation
Unless im doing it wrong
Or should I just get the data individually in each file component like this. Though it makes more db calls than the first picture