Balancing Server Loader Calls vs Client Cache Freshness in Remix Route Navigation
0 reputation · 14 Feb 2023, 06:13 UTC
Goal
Decide which Remix routes must call serverLoader() from their clientLoader on every client‑side navigation to serve server‑authoritative data, and which routes can safely rely on cached client data without that call.
Constraints and uncertainty
Remix’s documented loader split does not invoke the server loader automatically; invoking it adds server‑side work and may recreate the load you wish to avoid, while omitting it leaves data freshness to application policy and risks stale UI after mutations. Loader names (clientLoader, serverLoader, hydration fallbacks) and default behaviors vary across Remix/React Router versions, so the exact API to use is version‑specific. There is no built‑in default freshness policy, leaving the trade‑off between data freshness and server load as an unresolved decision.
Which routes should enforce a server call on every client navigation, and which can tolerate cached data? How can you evaluate the freshness‑vs‑load trade‑off for a given route without introducing instrumentation that alters the behavior you are measuring?