Next.js Discord

Discord Forum

How immediate is revalidatePath?

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Say I have a static api endpoint that stays static until some type of mutation happens from any user. Upon this mutation (as server actions) it will also call revalidatePath('/api/hello'). If someone fetches immediately, will nextjs/vercel give back the updated response? How does nextjs handle cache invalidation + stampeding if so?

Also, if i call revalidatePath('/api/hello') That would revalidate all children paths like '/api/hello/hi' and /api/hello/hi/1234 as well right?

6 Replies

Brown bearOP
and would the data be guaranteed to be refreshed?

I have a pattern of

server processes bunch of data, and revalidates a large endpoint, and publishes a websocket event to all the users to refetch the data.

The data should ideally be all the same across all the users
if you revalidatePath('/api/hello'), it will only revalidate /api/hello
you could do revalidatePath('/api/hello/[id]') and revalidatePath('/api/hello/[id]/1234')