Next.js Discord

Discord Forum

Everytime I call SWR will hit the database?

Answered
Brittany posted this in #help-forum
Open in Discord
BrittanyOP
I'm using useSWR inside a component, and I put one console.log inside the function. It's being called a lot of times just by clicking around, because it's in a sidebar. Is it everytime hitting the database to gather new info? Because it's useless for me, the database just refresh every 5 minutes.
Answered by Brittany
Thanks for the answers guys, what I did was using the dedupingInterval and focusThrottleInterval
View full answer

5 Replies

Northern Wheatear
Actually it is supposed to work like that
If you are fetching data from db using an api route you can implement caching
or try setting revalidateOnFocus to false
https://swr.vercel.app/docs/api#options
BrittanyOP
Thanks for the answers guys, what I did was using the dedupingInterval and focusThrottleInterval
Answer