Revalidation and Cache Invalidation on Dynamic Path
Unanswered
Champagne D’Argent posted this in #help-forum
Original message was deleted.
10 Replies
European sprat
Try router.refresh() instead of push
Champagne D’Argent
@European sprat
That would refresh the page at /movie/[movieID]/review
That would refresh the page at /movie/[movieID]/review
The page at /movie/[movieID] is the one I need revalidated 😦
European sprat
Ah sorry I thought it was sent back to the same page
Champagne D’Argent
I suppose I could turn the form into a modal and do a refresh, but I feel like next has this functionality with an api route for revalidate
European sprat
I think the issue is router push and replace so client soft navigation which doesn't refetch data, you can read a bit more about it here https://nextjs.org/docs/app/api-reference/functions/use-router
I actually ran into a similar issue with my app and ended up using react query in RSC and client components to keep things up to date
I actually ran into a similar issue with my app and ended up using react query in RSC and client components to keep things up to date
Alternatively I think you can use effect the pathname and so a router refresh
Champagne D’Argent
Someone else stated that setting the href on window does a hard navigation that would solve it elsewhere, but I havnt been able to test it
Other idea is to add an artifical but unneeded query to the url for the push
Champagne D’Argent
@European sprat
After getting a second to test it, using
provides the required functionality withtout any need for attempts at revalidation
After getting a second to test it, using
window.location.href = `/movie/${movie.id}`provides the required functionality withtout any need for attempts at revalidation