bug? revalidatePath doesn't work in nextjs15
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I've tried -everything-, from a route handler. server action, from trpc, from react after the mutation, the exact url, the dynamic route(it's a news site) and nothing, it won't show the new data.
"next": "15.5.12"
Any clue? I have another project with the same stack but with nextjs14 and it works fine.
"next": "15.5.12"
Any clue? I have another project with the same stack but with nextjs14 and it works fine.
5 Replies
Rottweiler
Next.js 15 caches data aggressively by default in app/ routes and server components. That’s why your new data isn’t showing. Try adding cache: 'no-store' to your fetch or use tRPC’s invalidate() after the mutation to refetch fresh data.
I would love to discuss in more detail via PM
Asiatic LionOP
Thanks for replying, this is a static page that i'm editing via admin panel, I tried to call revalidatePath inside a trpc procedure but it won't work(not sure why it works with nextjs14). Tried calling a server action inside trpc but no luck either
Rottweiler
That makes sense—Next 15 handles static and dynamic caching differently than v14. Even calling revalidatePath inside a tRPC procedure won’t work if the page is statically cached. You’ll need to either:
Convert the page or component to dynamic rendering (export const dynamic = 'force-dynamic') so it doesn’t serve the old static cache.
Or, use revalidatePath inside a server action triggered by the admin panel, not inside tRPC, because tRPC runs separately and may not trigger the static regeneration as expected.
Basically, Next 15’s caching is more aggressive, so static pages need explicit dynamic or revalidation setup.
Convert the page or component to dynamic rendering (export const dynamic = 'force-dynamic') so it doesn’t serve the old static cache.
Or, use revalidatePath inside a server action triggered by the admin panel, not inside tRPC, because tRPC runs separately and may not trigger the static regeneration as expected.
Basically, Next 15’s caching is more aggressive, so static pages need explicit dynamic or revalidation setup.
Asiatic LionOP
thanks for educating me, is this the same for Nextjs16?