I ran into a bit of an issue today and I need your help to figure out what the best approach is to solving browser navigation (user clicks browsers back/forward button) when using server components.
We use server components and in the page.tsx
we perform two api requests based on which we show data and redirect the user if needed. All works fine the first time a user enters the page. If the user clicks back in the browser navigation and then forward, the user sees the same data, i.e. it’s not refetched and the server component is not re-triggered.
I consider this expected, because server components spit out html code that is given to the browser so there’s no need for refetching the page from the server, but how do you handle validation in that case? Do you trigger a request from the client side and ultimately end up with the same request twice? Is there a way to force the refresh?
We tried disabling the cache and forcing dynamic route, but the browser does not re-request the page