router.refresh on SSG page doesn't work until unrelated SSR
Unanswered
Atlantic horse mackerel posted this in #help-forum
Atlantic horse mackerelOP
Hey there, I'm new to next.js and trying to wrap my head around everything.
I've set up 3 example components to demonstrate SSR.
1. SSR'd component with client side router.refresh()
2. SSR'd component with server action calling revalidatePath
3. SSR'd component with server action calling revalidateTag
These all work fine in next dev, but when I build and serve, #1 doesn't work until after I call 2 or 3. Then it works, even after page refresh.
My assumption would be that after hydration, router.refresh would work normally to trigger refreshes of RSCs. I can see in the network tab that router.refresh is fetching an update from the backend (?_rsc=1018j), but it's not getting rendered in the SSG'd page.
Is this expected behavior? If so, what's wrong with my mental model here.
I've set up 3 example components to demonstrate SSR.
1. SSR'd component with client side router.refresh()
2. SSR'd component with server action calling revalidatePath
3. SSR'd component with server action calling revalidateTag
These all work fine in next dev, but when I build and serve, #1 doesn't work until after I call 2 or 3. Then it works, even after page refresh.
My assumption would be that after hydration, router.refresh would work normally to trigger refreshes of RSCs. I can see in the network tab that router.refresh is fetching an update from the backend (?_rsc=1018j), but it's not getting rendered in the SSG'd page.
Is this expected behavior? If so, what's wrong with my mental model here.
1 Reply
Atlantic horse mackerelOP
nevermind, just went through all the caching documentation and answered my own question.
Yes this is expected behavior. router.refresh resets the client side cache, but not the server side cache.
Yes this is expected behavior. router.refresh resets the client side cache, but not the server side cache.