How immediate is revalidatePath?
Unanswered
Brown bear posted this in #help-forum
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
Also, if i 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
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
@Brown bear 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?
revalidatePath('/api/hello') -> mark the path to be ready for revalidation/api/hello hit -> showing stale data and revalidate in backgroud/api/hello hit -> show updated dataif you
revalidatePath('/api/hello'), it will only revalidate /api/helloyou could do
revalidatePath('/api/hello/[id]') and revalidatePath('/api/hello/[id]/1234')@Brown bear 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 this case, you should use a websocket server