Next.js · Senior · Question 36 of 75
How does refresh() from next/cache differ from revalidatePath?
- ✓Correct answer: It refreshes the client router without touching the server cache
- 2It completely clears the app's entire server cache
- 3It's a synonym for
revalidatePath('/', 'layout')
Explanation
refresh() in a Server Action makes the client router refetch the current page - e.g. to update a notification counter whose data isn't cached. If the data is cached, without revalidatePath/revalidateTag/updateTag the user sees the old value.