How to disable client side caching of server component routes in app router?
Unanswered
La Sagra's Flycatcher posted this in #help-forum
La Sagra's FlycatcherOP
I'd like to protect the /account route so I'm using middleware to see if a user session exists, and redirecting the user to /signup if none does. On my / route (which isn't protected) I have a <Link> to /account, which I expect to take me to /account when authed and /signup when not.
This works fine, except for a few minutes after auth state changes. If I just signed in, the homepage link still takes me to the /signup page, and if I just signed out, then the link still takes me to the /account page.
I believe this is because of client side caching of the /account page server component. I added a console log that prints what paths are being requested in my middleware.js and I can see that /account isn't being requested any clicks of the link except the first one.
How can I disable client side caching, at least for this route? I'd prefer not to use revalidatePath as it's an alpha feature and is giving me an error message. Is there any other way? Thanks!
Here's my github repo if you're curious, it's pretty simple code: https://github.com/bztravis/gifgrams
This works fine, except for a few minutes after auth state changes. If I just signed in, the homepage link still takes me to the /signup page, and if I just signed out, then the link still takes me to the /account page.
I believe this is because of client side caching of the /account page server component. I added a console log that prints what paths are being requested in my middleware.js and I can see that /account isn't being requested any clicks of the link except the first one.
How can I disable client side caching, at least for this route? I'd prefer not to use revalidatePath as it's an alpha feature and is giving me an error message. Is there any other way? Thanks!
Here's my github repo if you're curious, it's pretty simple code: https://github.com/bztravis/gifgrams