Web rendering strategies

30 May 2022

Knowing how to render can make your website faster, cheaper to host, and easier to develop. Also, there's no such thing as the best rendering method. You have to choose the most suitable one for each page.

Static Site Generation (SSG)

HTML is generated at build time. This generated HTML is reused every time someone visits your web page and can be cached by a CDN. Use SSG for blog, documentation, marketing page, etc.

Pros

Cons

Incremental Static Regeneration (ISR)

This is similar to SSG. But instead of rebuilding the site every time, you set revalidate time (for example, every 10 seconds). I personally like to think of this as "Time-based" ISR.

Pros

Cons

On-demand Incremental Static Regeneration

This is similar to SSG but only regenerates when an event happens. This event can be a change in the database for example.

Pros

Cons

Server-Side Rendering (SSR)

This generates HTML every time someone visits your web page. This is good for websites with dynamic data and a lot of different pages. Use SSR for newsfeed, chat app, etc.

Pros

Cons

Note: most of these cons can be solved with a CDN but I won't write about it here. Vercel is currently exploring Edge SSR. Edge basically means "globally distributed". Edge SSR will also have near-zero cold boots.

Client-Side Rendering (CSR)

First, the browser loads an HTML with little to no content. Then, it fetches JavaScript and compiles everything. If the user disabled JavaScript, your website won't work.

Pros

Cons

How to choose

Here's an oversimplified guide to choosing a rendering method. This might be wrong in some cases.

Rendering decision

Read other blogs