#revalidatePath takes effect only once
1 messages · Page 1 of 1 (latest)
Hi @smoky quarry. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the available knowledge sources, there is no explicit documentation or official statement that says revalidatePath only takes effect once per path. The documented behavior is:
- When you call revalidatePath for a specific path, it invalidates the cache for that path. The next visit to that path will trigger regeneration and serve fresh data, which will then be cached for subsequent requests. If you call revalidatePath again for the same path, it should invalidate the cache again, and the next visit will again trigger regeneration and caching of fresh data. This process can be repeated as needed; there is no mention of a one-time limitation in the official docs or examples How to implement Incremental Static Regeneration (ISR) revalidatePath API reference.
However, there are some open and closed GitHub issues reporting bugs or unexpected behaviors with revalidatePath, especially in complex scenarios (e.g., dynamic routes, multi-tenant setups, or when used with <Link> navigation). These issues sometimes result in the cache not being invalidated as expected, but they do not indicate that revalidatePath is designed to work only once per path. Instead, they point to possible bugs or edge cases in the current implementation revalidatePath fails to invalidate cache for specific dynamic paths <Link> disturbing revalidation for dynamically generated routes.
In summary:
revalidatePath is intended to work every time it is called, invalidating the cache for the specified path on each invocation. If you are experiencing it taking effect only once, it may be due to a bug or a specific edge case in your application, not by design. If you have a reproducible example, consider checking for related open issues or reporting it to the Next.js team.
If you need more details about your specific scenario, please provide more context or code examples.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@smoky quarry Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@woven moat There are three apis on my page and I have set up isr. Now when I execute revalidatePath, the data can be reloaded for the first time, but the latest data cannot be retrieved again when I execute revalidatePath later
Let me check the knowledge base for you again. Give me one moment! :books:
Based on the knowledge sources, your issue—where revalidatePath only reloads data the first time, but not on subsequent calls—matches several known problems and caveats with ISR and on-demand revalidation in Next.js.
Key Points from the Knowledge Sources
- revalidatePath is designed to invalidate the cache for a specific path, so the next request to that path should fetch fresh data and update the cache. This process should work every time you call revalidatePath, not just once How to implement ISR: Examples revalidatePath API reference.
- However, there are multiple open issues where revalidatePath does not work as expected, especially when:
- There are multiple data sources or APIs on the page.
- The page uses dynamic routes or complex caching/tagging strategies.
- Multiple revalidateTag or revalidatePath calls are made in a single request—sometimes only one tag/path is actually revalidated, and others are ignored. This is a known bug Revalidation of multiple tags at once fails.
- The cache is not properly invalidated for all data sources, especially if you use tags or unstable_cache for granular control revalidatePath with middleware doesn't work on multi-tenant project.
Possible Reasons for Your Issue
- If your three APIs are cached with different tags or cache keys, revalidatePath may only invalidate the path cache, not all underlying data. If you use fetch with next: { tags: [...] }, you may also need to use revalidateTag for each tag Relationship with revalidateTag.
- If you are calling revalidatePath or revalidateTag multiple times in a single request, only one may take effect due to a known bug Revalidation of multiple tags at once fails.
- If you are using dynamic routes or complex middleware, ensure you are revalidating the exact path as seen by the router, not a rewritten or aliased path Caveats.
What You Can Try
- Make sure you are calling revalidatePath with the exact path as rendered.
- If your APIs use tags, also call revalidateTag for each relevant tag.
- If you need to revalidate multiple tags or paths, consider making separate API calls for each, as a workaround for the bug.
- Check if your data fetching uses unstable_cache or fetch with tags, and ensure your revalidation matches the caching strategy.
Summary
Your experience is consistent with known issues in Next.js ISR where revalidatePath (and revalidateTag) may not always work as expected, especially with multiple data sources or repeated calls. This is not the intended behavior, but rather a limitation or bug in the current implementation Revalidation of multiple tags at once fails revalidatePath with middleware doesn't work on multi-tenant project.