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 start3 Replies
American CrocodileOP
Are we certain this is the issue. This is a page that uses a param, so it should be dynamic always right? I tried doing force-dynamic as well same result.
What weirds me out here is that it only happens first time. So if I go back to the page, forwards again and back again, these are all client routing I think, but the issue is only the first time.
What weirds me out here is that it only happens first time. So if I go back to the page, forwards again and back again, these are all client routing I think, but the issue is only the first time.
American CrocodileOP
This is so weird. I'm not sure where I should do any of this. The page being navigated from is a server rendered page, with a Link component. So do I need to change that to a client component and call a server action to revalidate ?
Trying to read up on disabling the router cache for version 15 I get this from the documentation.
[Opting out
As of Next.js 15, page segments are opted out by default.](https://nextjs.org/docs/15/app/guides/caching#opting-out-3)
So I'm not getting how I would do that.
Trying to read up on disabling the router cache for version 15 I get this from the documentation.
[Opting out
As of Next.js 15, page segments are opted out by default.](https://nextjs.org/docs/15/app/guides/caching#opting-out-3)
So I'm not getting how I would do that.
American CrocodileOP
Also if it is cached, why does it not have the previous data, why isn't the client component initialized with cached data.
There has been no change to the data, the user moves to an overviewPage, that just presents the data in a different way, and then navigates back to the "edit" page. The issue isn't that the data has changed and we are getting stale data, its just that the page now has no data. Nothing at all.
There has been no change to the data, the user moves to an overviewPage, that just presents the data in a different way, and then navigates back to the "edit" page. The issue isn't that the data has changed and we are getting stale data, its just that the page now has no data. Nothing at all.