Data Freshness Trade-offs
You'll learn how CSR, SSR, and SSG handle real-time data differently, and what trade-offs each approach makes between freshness and performance.
The Freshness Spectrum
Data freshness refers to how up-to-date your content is when users see it. Each rendering approach handles this differently:
CSR (Client-Side Rendering) fetches data after the page loads in the browser. Every visit means a fresh API call, so users always see the latest data. Think of it like checking your phone for new messages—you get real-time updates, but you have to wait for the check to complete.
SSR (Server-Side Rendering) fetches data on every request at the server level, then sends complete HTML. The data is fresh for that moment, but if something changes after the HTML is sent, the user won't see it until they refresh. It's like reading today's newspaper—current when printed, but not updating live.
SSG (Static Site Generation) with stale-while-revalidate is a hybrid approach. Users get pre-built content instantly (potentially stale), while the system checks for updates in the background and refreshes the cache for the next visitor. Imagine a store display that's restocked nightly—you see yesterday's arrangement quickly, but tomorrow it might be updated.
Choosing Your Trade-off
- Need real-time data? CSR shines for dashboards, live feeds, or user-specific content
- Need fresh-enough data with fast initial loads? SSR balances both reasonably well
- Content changes infrequently? SSG with periodic rebuilds gives blazing speed with acceptable staleness
- Best of both worlds? SSG +
stale-while-revalidateserves cached content instantly while updating behind the scenes
Key Takeaway: CSR prioritizes freshness over initial speed, SSG prioritizes speed over freshness, and SSR sits in the middle—choose based on how critical real-time data is to your user experience.