Static Site Generation vs Server-Side Rendering
Both send ready-made HTML. Static site generation builds each page once, ahead of time. Server rendering builds it again for each visit, so it can show fresh data.
Static Site Generation (SSG)
Pages are built as HTML files ahead of time. Then no one has to wait.
Static site generation builds each page as an HTML file ahead of time. This happens before anyone visits. A build step reads the content and templates and writes out the files. The server then just hands out those files, which is very fast and cheap. When the content changes, you run the build again. It suits blogs, docs and any page that is the same for everyone.
Server-Side Rendering (SSR)
The server builds the full page for each visit. It arrives ready to show.
Server-side rendering means the server builds the full page for each visit. It sends HTML that is ready to show. The user sees content at once, before any JavaScript runs. Search engines can read the page with ease too. The cost is more work on the server each time. Many new frameworks mix it with browser code, in a step called hydration.
In one line
- Static Site Generation (SSG)
- Pages are built as HTML files ahead of time. Then no one has to wait.
- Server-Side Rendering (SSR)
- The server builds the full page for each visit. It arrives ready to show.