Trying to better understand caching
Unanswered
Gouty oak gall posted this in #help-forum
Gouty oak gallOP
Using the app router I have a page.tsx that looks like this:
The getUserVideoRequests function makes a call directly to a database to query a list of items. What I am finding is sometimes when clicking a link to this page the query is not run (if I click refresh it is). I'm assuming this is because of nextjs thinking this is a static url and since there is no fetch it doesn't treat it dynamically. What is the right way to control this?
const ViewMyRequests = async() => {
const session = await getServerSession( authOptions);
if (!session || !session.user){
redirect('/signin');
}
const userid = session.user.id;
const userdetails = await getUserDetails(userid);
const results = await getUserVideoRequests(userid);
return (
<>
<div className="container">
<div className="w-full py-4 px-8">
<RequestTable results={results}/>
</div>
</div>
</>
)
} The getUserVideoRequests function makes a call directly to a database to query a list of items. What I am finding is sometimes when clicking a link to this page the query is not run (if I click refresh it is). I'm assuming this is because of nextjs thinking this is a static url and since there is no fetch it doesn't treat it dynamically. What is the right way to control this?
6 Replies
Gouty oak gallOP
Is there a way to tell if your route is being statically or dynamically rendered?
there is a report after you run next build
Gouty oak gallOP
Thank you, never noticed the icons. So my page in question is dynamic, so it sounds like I'm hitting that 30 second thing. It also sounds like I could avoid this by triggering
revalidatePath when something changes in the DB? Does that sound right?yes