Junior — Middle
What is the difference between static site generation (SSG) and server-side rendering (SSR)?
sobes.tech AI
Answer from AI
Static Site Generation (SSG) is the process where HTML pages are pre-built during the application's build time. These pages are stored on the server and served to the client without additional processing. This ensures fast loading and good performance, as the server simply delivers the ready-made file.
Server-Side Rendering (SSR) is the process where an HTML page is dynamically generated on the server for each user request. The server executes the application code, generates the HTML, and sends it to the client. This allows displaying up-to-date data and improves SEO, but can be slower due to the server-side generation time.
Example:
- SSG: a blog site where articles rarely change — pages are generated once and served quickly.
- SSR: an online store with constantly updated inventory — pages are generated for each user with current information.