Why does Volto re-fetch the SSR'd content page?

I'm looking at trying to reduce the number of unnecessary requests from the client and am wondering why Volto re-runs the content API after doing it's initial SSR request? Is it not enough for the redux store to be filled based on the SSR-fetched content?

I had the same question. I think you're correct, Volto shouldn't do an additional request on client, immediately after SSR rendering.

As far as I'm concerned, the getContent here in the View is not correct. We should remove the __SERVER__ condition and try to fix the remaining issues here: https://github.com/plone/volto/blob/59cb378e831eb439e306b264bee97aa4bff563f6/packages/volto/src/components/theme/App/App.jsx#L280

It's possible that that wouldn't be enough and we need a way to check if the store is already populated for the content. I think @sneridagh 's @plone/client work is intended to fix all these issues by being smarter about the way we do network fetching by relying on having this problem (data hydration via SSR) solved by the upstream react-query library.

In any case, we'd still have to check if the data is actually compatible, in the past I've seen redux data content store being different from the client-side fetched data. There's a proof of this in this code: https://github.com/plone/volto/blob/59cb378e831eb439e306b264bee97aa4bff563f6/packages/volto/src/reducers/navigation/navigation.js#L36

1 Like

Indeed, this is because how we do SSR using AsyncConnect, and has been unavoidable since the beginning due to the isomorphic nature of it.

If we ever move to @plone/client and ReactQuery, then we will solve it.