revalidatePath("/") not working
Answered
Chinese Alligator posted this in #help-forum
Original message was deleted.
29 Replies
Revalidate doesn't run the code untill there is a request for it (just deletes cache)
Bullmastiff
I am having this issue as well and its a major blocker for our client deployment
Define "not working". Does it load the updated page on next access of hompage?
Bullmastiff
Revalidation is not working in next.js v13.
I am using /pages and setting revalidation: 10 in my staticProps. I have used revalidation successfully on next 12.
When I make an update in my CMS (Contentful). If I browse to my homepage through the url, after 10 secs the revalidation works.
However when I click the top left logo which uses <Link href={"/"}> it always uses the cached page and it never updates. Leading my client to think the content they updated has reset. This happens on all links. If I go to the page through browser url the revalidation works. I have tried in 13.3.0, 13.4.19, 13.5.3 and other versions. Desperate to find a solution for this. At this point I am almost positive this is broken in next.js.
I am using /pages and setting revalidation: 10 in my staticProps. I have used revalidation successfully on next 12.
When I make an update in my CMS (Contentful). If I browse to my homepage through the url, after 10 secs the revalidation works.
However when I click the top left logo which uses <Link href={"/"}> it always uses the cached page and it never updates. Leading my client to think the content they updated has reset. This happens on all links. If I go to the page through browser url the revalidation works. I have tried in 13.3.0, 13.4.19, 13.5.3 and other versions. Desperate to find a solution for this. At this point I am almost positive this is broken in next.js.
Bullmastiff
@riský
It is also app dir only iirc
Bullmastiff
you mean revalidation?
Ive used it in version 12 and its still supposed to work in 13 with pages directory
I'm talking about the revalidate path function, in your page it does revalidate, but not the same way
Also is there client cache for your pages when using next/link?
Bullmastiff
It does seem to be related to next/link
next/link uses stale cache content always
but refreshing the page or entering through browser url always gets the revalidated content
Disable prefetch or use router.reload (idk it pages router does same thing tho)
Bullmastiff
So use reload on every link?
feels very hacky but not a bad idea
Well refresh if your client modificatied something
And disable prefetch to make it harder to get stale data
Other wise you can use basic a link or refresh after (not the best tho)
Bullmastiff
need some validation (pun) from next.js this is an actual issue or if there is an actual workaround.
(this question is common, but no real way that I know of doing the nice change but have new data)
Bullmastiff
have spent a lot of extra time troubleshooting something that seems to be an issue in next.js
I wouldn't call it an issue, just something that the team doesn't think needs to be implemented (I wish there was a disable cache method)
Or at least swr like using cached data but then get new data (you can kinda with .refresh but if it isn't cached, that's 2 reqursts)
@riský Revalidate doesn't run the code untill there is a request for it (just deletes cache)
Chinese Alligator
ahhh , so to see the new post i added i have to do a new request to the database manually ?
I mean when you revalidate homepage, you have t reload the page to see the query
Chinese Alligator
i understood the problem now , but still can't find a fix , NewPost is the component that adds the new post, but the PostQuoteSelector is the component that shows them , i could use router.refresh() but it would relead only the component from which is called(NewPost), how can i refresh PostQuoteSelector after addig a new post in NewPost? (both are client components)
router.refesh reloads the whole page effectivly
Answer