Skip to content

How do you choose between CSR, SSR, SSG and ISR?

IntermediateAsked very oftenSystem designDesignArchitecture
Asked atVercelShopifyNetflix
#next.js#rendering#architecture#caching#trade-offs

Company tags are compiled from public interview reports and are signals, not guarantees.

What interviewers are testing

Rendering strategy is the first architecture decision in any modern fullstack app, and it exposes whether you weigh trade-offs or recite framework defaults. Interviewers listen for the axes: freshness, personalization, SEO, and cost. Strong candidates pick per route — a marketing page and an admin dashboard in the same app rarely want the same answer — and can name what each choice does to first paint, caching, and hydration.

Mental model

Reframe the acronyms as one clock: when is the HTML built? At build time (SSG), per request (SSR), after first paint in the browser (CSR), or at build time with scheduled rebuilds (ISR). Every trade-off follows from that clock plus one hard constraint: who is allowed to see this page — everyone, or only the person logged in? Cached HTML and personalization do not mix.

Step-by-step solution

  1. Step 1: Client-side: the blank first paint

    Start from the failure mode that made SSR popular again. In a pure CSR app the server ships a nearly empty HTML shell plus a JavaScript bundle; the browser must download, parse, and execute the bundle before it can fetch data and paint anything meaningful. The navigation looks instant on a fast laptop with a warm cache, and disastrous on a mid-range phone on 4G — the user stares at white for seconds. The trade-offs to name: per-request server cost drops to zero and client navigation is frictionless, but first paint is the slowest of all strategies, the HTML shell is invisible to crawlers and link previews, and every new user pays the full boot cost. Watch the animation: the screen lane stays blank until the very end, no matter how fast the server was.

  2. Step 2: Static: build once, serve from the edge

    The opposite pole: render every page to HTML at deploy time, with its data already baked in, and copy the files to CDN caches worldwide. A visitor anywhere gets finished HTML from a nearby edge in single-digit milliseconds — no origin server, no database, no per-request render. This is the cheapest and fastest strategy, and it scales by default on a CDN budget. Its one weakness is the freshness clock: content is as old as the last deploy. That is perfect for blogs, docs, and marketing pages whose changes you control, and wrong for anything that changes on its own schedule. Watch the animation: the build is the only expensive step, and the visitor never touches the origin.

  3. Step 3: Per request: server-render the answer

    When the page depends on who is asking — a dashboard, an account page, a search result — no shared cache can hold it. SSR renders the HTML on every request: the server runs the data queries, produces complete markup for this specific user, and sends it back ready to paint. First paint shows real content, crawlers and previews see full HTML, and personalization is safe because nothing is shared. The price is structural: every request pays render time plus query time, the CDN helps little because responses are per-user, and the server fleet must scale with traffic instead of a static file cache. The design instinct to voice: cache what is shareable, render what is personal, and never let a CDN cache a page containing someone else's name.

  4. Step 4: The middle ground: ISR (stale-while-revalidate)

    Most content is not per-user and not per-deploy either: product listings, news, catalogs — shared by everyone, changing on their own schedule. ISR treats the page as a cached static file with a TTL, and adds one rule that makes it scale: when the cache expires, the next visitor still gets the stale copy instantly while a single background rebuild runs. Freshness arrives seconds later, for everyone, without any visitor waiting and without a rebuild per request. This is the stale-while-revalidate family of design — the same move HTTP caching uses — and it is why the pattern dominates e-commerce and content sites. Watch the animation: precisely one rebuild per interval, no matter how many visitors hit the stale window.

  5. Step 5: Making the decision per route

    The real interview answer is a mapping, not a favorite. Start from the content clock: if you control when content changes, static wins — SSG, or ISR when it changes between deploys. If each response depends on the requester, the cache is off the table: SSR, with per-user cache keys only if you are certain about the boundaries. If SEO and first paint are business-critical, the blank shell of CSR is disqualified before performance even enters the conversation. And when none of the hard constraints apply — a logged-in internal tool, an interactive editor — CSR quietly wins on simplicity and infrastructure cost. Modern frameworks make this per-route, so one app can mix all four; the skill being tested is knowing which clock each route runs on, and naming the one constraint that eliminates an option outright.

Edge cases & traps

  • Cached HTML and auth do not mix: a CDN-cached SSR page served to the wrong user leaks data — vary the cache key per user/session or keep personalized fragments client-side.
  • ISR serves stale on the expired hit: the first visitor after expiry gets the old page while the rebuild runs, so the design must tolerate one outdated response.
  • SSG at scale means long builds: 100k product pages regenerated on every publish can be worse operationally than SSR behind a cache — shard, or move to on-demand revalidation.
  • Hydration errors are the hidden invoice of SSR: server markup must match the first client render exactly, or the framework throws the HTML away and re-renders from scratch.
  • CSR is not invisible to SEO but it is late: crawlers execute JavaScript today, yet first paint, social previews, and slow devices still suffer without prerendered HTML.

Follow-up questions

Go deeper: Explore the Next.js visualizer