Next JS Caching Doubts
I am trying to get familiar with next js by following one of the projects in the youtube. Using next js v15, I have a postgres db with drizzle ORM, Using server actions to fetch the data. So I have a home page which lists the data by fetching from the server. in the dev mode, the data is fetching dynamically for every render where as when i try to build for production. the home page is prerendered and its giving the same data everytime. I want it to be specific for each user when they authenticate. I have Gone through docs , I have found two options either exporting or using revalidate property to rerender after certain period of stale time. What is the best approach in these situations? please suggest me your way of approaching that would be helpful.
5 Replies
dashboard.tsx
InvoiceDetails.tsx
server action
just following up on this.
It just depends on what the data is. ISR is clearly better if staleness is acceptable
Generally speaking it's not the case for user specific data
so in case of user specific data, force dynamic rendering would be better option?
Yup
Or well, it depends on how tollerant you are about the user seeing stale data
If the only data loaded in the page isn't supposed to be completely up to date (i.e. a feed of user recommendations which are personalized but don't necessarily have to be 100% fresh) then you can ISR
But in your case it looks like you're handling invoices which I assume are supposed to be present in the dashboard as soon as one is inserted in the db
And in that case you want to force dynamic rendering yeah
got it, thanks for your insights