Next.js caching
Hey guys, I'm having a hard time understading what is wrong here. I made a simple repo: https://github.com/HellYeahOmg/revalidate-test
Main page has a get request for some items, the second page has a form to add items. After submitting the form i expect to see the updated result on the main page.
I added every disabling cache option i could, but it still doesnt work unless i hit router.request() or revalidatePath(). Why so?
GitHub
GitHub - HellYeahOmg/revalidate-test
Contribute to HellYeahOmg/revalidate-test development by creating an account on GitHub.
8 Replies
you should try opting out of the cache for the fetch
Data Fetching: Fetching, Caching, and Revalidating | Next.js
Learn how to fetch, cache, and revalidate data in your Next.js application.
@nyx (Rustular DevRel) i of course tried, but my mistake i didnt commit it
updated the repo, main page has
export const dynamic = 'force-dynamic'
export const revalidate = 0
and the get request also has cache: 'no-store' policy
caching on nextjs sucks
but to bust the cache you need to revalidatePath() from itself or from a server action
tho it works for that particular simple case, it doesn't work with the case im facing in prod rn
https://github.com/HellYeahOmg/revalidate-test/tree/long-async-request
While sending a heavy request from the main page, users can navigate to other pages, and in that case even revalidatePath (or revalidateTags) doesnt help...
GitHub
GitHub - HellYeahOmg/revalidate-test at long-async-request
Contribute to HellYeahOmg/revalidate-test development by creating an account on GitHub.
i wonder what all those setting do if they dont help
¯\_(ツ)_/¯
i'll try yo help u bro