Next.js Discord

Discord Forum

Dynamic rendering do not refetch certain queries.

Answered
Siamese Crocodile posted this in #help-forum
Open in Discord
Siamese CrocodileOP
Hi my app is dynamically rendered because of checking cookies for user authentication in main layout (it makes all pages dynamic).

Some pages have data that I do not want to fetch on every request like cms content but I want to fetch dynamically other data that this page uses.

// page.tsx
// dynamic rendered page
export async function Page(){
  // fetch it once during build and revalidate on demand or every 1h or so
  const cmsData = await getCmsData()

  const users = await getUsers() // fetch it dynamically and do not cache


How can I achive it?

20 Replies

Siamese CrocodileOP
And when getCmsData doesnt use fetch
but graphql-request
or prisma directly?
@Ray
Answer
Siamese CrocodileOP
So when someone goes to /home and fetches the cms data

Then when another person enters /home we have cms data in cache?
and its not fetched?
yes
Siamese CrocodileOP
Sure
Thanks
Siamese CrocodileOP
@Ray what about cache from react
I can't understand a difference
@Siamese Crocodile <@743561772069421169> what about cache from react
cache from react is mainly for dedup, it doesn't store the result to data cache
Siamese CrocodileOP
From my understanding next stores data in server cache and react only stores IT client side
when the request is finished, the data is gone
Siamese CrocodileOP
Aight
Siamese CrocodileOP
Thanks!