Next.js Discord

Discord Forum

revalidatePath with /pages router and SSR

Unanswered
Eloy posted this in #help-forum
Open in Discord
Avatar
EloyOP
Does this work?

I have a dynamic SSR page (getServerSideProps) that cannot be converted into SSG or ISR. I'm on NextJS 12 hosted on Vercel, using the /pages router.

I want to start caching said page, something like "guides/[guide]", and was wondering if revalidatePath works in this environment or if it only works for /app directory.

Thanks!

6 Replies

Avatar
joulev
I don’t think revalidatePath works there, but you have res.revalidate() in pages router api routes
Avatar
EloyOP
Interesting! I will try it out, thanks
Since it's in the docs under ISR I thought it only would apply there, but taking a closer look maybe it will work with SSR too.
Avatar
joulev
Eh, no it wont work for SSR. In the pages router there are no caching for dynamically rendered pages at all, and if you introduce custom caching techniques you need to manually implement caching invalidation yourself
Avatar
EloyOP
Oh so if I set the Cache-Control header for that page (/guides/[guide]), there is no built-in way of invalidating it when, for example, someone performs an edit action?