Slow API response time until sign out & sign in again

I'm having a weird issue with slow response times. I'm integrating Better-Auth with my Next.js app and I noticed that if I'm signed in to my dashboard and then stop and start the Next.js dev environment again using pnpm run dev my api calls are super slow - around 1 ~ 3 seconds. This happens only when I stop the server (without signing out) and start it back again. The app seems to be super slow. What seems to fix it is to sign out and sign in again, then it gets back to nromal and the GET calls drop do 20 - 250ms. Until of course the next time when I stop the dev server and start it back again.

Did anyone else noticed such issue?
CleanShot_2025-04-04_at_12.58.26.jpg
CleanShot_2025-04-04_at_12.59.30.jpg
Solution
I don't think there is much else you can do.
Alternatively you can setup secondary storage and use something like Redis from upstash if you want sessions to get to your client faster.
Was this page helpful?