#How to invalidate Route cache for a specific path on the client?

2 messages · Page 1 of 1 (latest)

stray igloo
#

I have a button that will POST a resource via API (POST /diagrams). If a user then navigates to the resource page (/diagrams), and the navigation is not the initial one, the data is stale. I've read this article https://nextjs.org/docs/app/building-your-application/caching, and in the Route cache section (I assume this is this one, because no API request is made upon navigation) it tells that you can either invalidate the route in the server actions (I'm not using them), or only the current route with router.refresh. However, I want to invalidate the specific /diagrams page after clicking the button. How do I do that? The page itself is dynamic (it uses cookies)

fervent bloomBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)