Routing back onto a page results in missing data
Unanswered
American Crocodile posted this in #help-forum
American CrocodileOP
So I´m sure this is a caching thing, something I might be misunderstanding. This is next.js version 15.2.6
I have a server component page that fetches data via HeyApi generated code (with their nextjst plugin) and than it uses that data to render a client sided zustand state provider ( there is some client based logic here ). This works fine, I have a path like
If you initially press this back button, or if you do the browsers back button, initially the page renders again, but not with any data. The async code on the initial page is not ran again, only the state provider thing is run but with no data. Refreshing on the page, or going forward and back again results in revalidation or something and data reappears.
Setting cache: 'no-store' doesn't help. Anyone getting what is happening here?
EDIT: Forgot to mention, this behaviour does not happen when running
I have a server component page that fetches data via HeyApi generated code (with their nextjst plugin) and than it uses that data to render a client sided zustand state provider ( there is some client based logic here ). This works fine, I have a path like
/path/{id} and routing to that path with data already present renders out fine. I press button to go to next page, on that page I have a button that routes back to this page.If you initially press this back button, or if you do the browsers back button, initially the page renders again, but not with any data. The async code on the initial page is not ran again, only the state provider thing is run but with no data. Refreshing on the page, or going forward and back again results in revalidation or something and data reappears.
Setting cache: 'no-store' doesn't help. Anyone getting what is happening here?
EDIT: Forgot to mention, this behaviour does not happen when running
next dev, only in next start1 Reply
Western paper wasp
Hi. This is a well-known edge case with RSC cache/router cache in
next start. It looks like restoring a page from the client cache without re-fetching it from the server. You need to dig into the router cache, fetch cache, and revalidatePath / revalidateTag.