Website Creation —

SSG Static Site Generation VS. SSR Server-Side Rendering?

By Arso Stojović
5 min
Published on September 21, 2022
Updated on November 29, 2022
Share it on:
SSG vs. SSR

The two most common approaches to creating websites using modern front-ends are server-side rendering (SSR) and static site generation (SSG), but they are also different in several ways. Each approach has a type of content that benefits from the front-end pattern and use cases where it makes sense. If dynamic content requires a high level of personalization, SSR is likely to be more appropriate. On the other hand, static, SEO-optimized content may be better suited for SSG sites.

  • The first BCMS instance is free

  • Free migration

  • Free support

  • No credit card needed‍

Create your account

What is SSG?

Static Site Generators generate content at the build time of new pages or when changes are made to the content. Because the SSGs are creating static sites, there is no need to load pages based on user requests. The content will remain consistent regardless of users. By incorporating SSGs into the tech stack, teams can access multiple data sources and use the latest web development approaches. Content that does not require high levels of personalization is ideal for the SSG approach. It is common to use static website generators alongside headless CMSs, static hosting sites, and CDNs.

How does SSG work?

SSG workflow

A static site generator generates an entirely static HTML website using raw data and a set of templates. In essence, a static site generator automates the process of coding individual HTML pages and serves them to users in advance.

An SSG receives a webhook notification when there is a change to the content, and the changes are deployed and cached on the site. Team members can store pre-rendered HTML files in close geographical locations, reducing web page load time.

Why use SSG?

The SSG approach is suitable for building applications where the content does not change too often, and it can bring many benefits, such as:

SSG sites are extremely fast

Since HTML does not require much processing upfront, serving an HTML page is much faster for users. Because all of your site's pages and content were generated during the build process, the client will begin seeing content immediately.

SSG is better for SEO

Search engines like HTML content, and that's why SSG is crawlers' favorite, and your site can become Google's fav too.

Empowered security

The risk of cyber attacks is minimal, thanks to the lack of databases.

SSG is cost-effective

There is no server! That means your hosting plans cost you, mmmm 0$ 🤩

Caching with CDNs

HTML pages offer CDN caching the opportunity to shine. It is much faster to access pages because they are stored nearer to the user globally. With CDN, you no longer have to wait for the server to render the page but receive it from the CDN, saving resources and money.

SSG back draws

  • Not suitable for highly dynamic or customizable content

  • It can be slow when it comes to rebuilding large sites

  • Hard to keep it up-to-date if there are often changes

When to use SSG?

As long as you have the option to render pages at the build time, you can use SSG for any set of circumstances. Even though there are sites for which SSG is an indispensable solution:

Documentation websites

SSG is the best choice for these kinds of websites. Why? Documentation sites don't have dynamic content; rendering them on the server per request would be supererogatory and slower. By using SSG, the content will be delivered quickly. 

Blog

Although blogs can have dynamic content and be more vivid than documentation websites, I would choose SSG again. Some new technologies and approaches make SSG more practicable. Nowadays, Headless CMSs help you store and fetch data at build time. The best practice for how this combo is efficient is the most common integration between Headless CMS and Jamstack. This integration is pretty simple and extremely fast.

Your static front-end project is rebuilt when a new blog post is submitted through your headless CMS. The static site is updated with fresh content with just one click when you add a new blog post. By using a CDN, it still loads extremely fast. In the end, you get a super-fast and secure blog like this BCMS you are reading right now.

Marketing & Portfolio websites

Popular frames like Gatsby, Nuxt.js, Hugo, and Jekyll are the typical choices for building marketing websites that can quickly scale or smaller projects like portfolio sites. Utilizing the PRPL pattern, these sites load as fast as possible by first loading only the most essential HTML, data, CSS, and Javascript.

What is an SSR?

Server Side Rendering is like Static Site Generation, except that you render the pages at runtime instead of at build time. Also, another crucial difference is that with SSR, you can't provide UI without a server. 

SSR is the perfect solution for dynamic content experiences and personalization. 

Instead of waiting several seconds for specific elements to load, SSR provides clients with a fully rendered page on demand. Before passing them on to the browser, the server renders them. A database or headless CMS provides data to a client when content is requested. Although loading everything on demand takes longer, it ensures that content is current and that any changes are immediately visible.

How does SSR work?

Besides having a server, SSR generates data way differently than SSG.

SSR workflow

SSR flow goes like this: 

The user in a browser requests a web page from a server, then the server generates HTML output and sends it back to the browser to show you the web page.

But does SSR why generate the output at every request? 

The answer is no!

In situations where the page is dynamic, such as user-specific content, server-side rendering makes sense, and the web page is generated every time the page is requested. Regenerating the output always makes no sense if the output is always the same.

Why use SSR?

It is highly recommended to use server-side rendered sites for time-sensitive content and applications that rely on a high degree of user interaction. E-commerce can benefit from SSRs since personalization is much easier. When using SSRs, ensure your infrastructure can handle the traffic and that the servers scale quickly as traffic increases.

SSR provides instantly accessible content

Content on demand is actually content on the go. That means that after the client's request, SSR sends the rendered HTML to the client, who will start seeing the content almost immediately. This way, content is always up-to-date.

There is no content rebuilding

Unlike SSG, you don't have to think about content rebuilding with Server Side Rendering because changes to content are displayed instantaneously.

Content sharing

A snippet with an image and a title is automatically created when a social network user posts a link to a server-side rendered application.

SSR Content Sharing

This excerpt gives viewers a sneak peek at the website and provides more details about the link's contents. Therefore, social network snippets might assist you in increasing traffic by drawing attention to the content of your application, like the one above about Programmatic SEO.

Integration with proprietary tech stacks

To improve personalization, the server-side opens the door for direct integration with internal systems such as inventory and headless CMS.

SSR back draws

  • The server is mandatory, which makes SSR more expensive.

  • It is not possible to deploy to a static CDN.

  • SSR, by default, is slower than SSG. 

  • Incompatible with some UI libraries

When to use SSR?

SSR is suitable for building complex web applications that require user interaction, rely on a database, or have frequently changing content. Since the content on these sites changes frequently, users need to see the updated content as soon as it is available. So if you want to have some of these kinds of sites, consider SSR: 

E-commerce

E-commerce sites are the ones that change frequently; users have the most requests for them; that's why SSR is the perfect choice for e-commerce.

Social media site

These are places where content changes from second to second. These types of sites are very dynamic and personalized because most of the content is created by the users. For such platforms and interactions, the choice should be SSR.

Media sites and apps

SSR is best for heavily text-based web apps, like written media apps and websites. Being up-to-date is one of the most important things for this kind of platform. SSR can provide that all necessary information and breaking news can be delivered as soon as possible to all clients across the world.

Rendering frameworks for each mode

SSG or SSR table

So, SSG or SSR - which one to use?

Ultimately, I would say there is no war between these two approaches. Both are powerful tools that can help you achieve your goals. Speaking of goals, they can help you see which option is better for your business.

Both approaches allow you to integrate with other robust tech solutions and options, such as Headless CMS, which can help you manage your content more effortlessly. Also, when we speak about tech stack, don't forget that Jamstack is one of the most popular and first choices for both kinds of content because even if it is static, it proved that it could handle any content successfully.

The way I see it, if I have to choose, I will go static anytime unless the website is extensive, the content is constantly changing, and the user needs it to be always up-to-date.

Luckily, whatever approach you choose, BCMS works wonderfully with SSR and SSG.

  • The first BCMS instance is free

  • Free migration

  • Free support

  • No credit card needed‍

Create your account