Server Side Rendering (ssr)

Server Side Rendering (ssr)

What is SSR?

Server-side rendering is the process of generating HTML pages on the server on the request of a webpage. Instead of rendering of the website's content on the client side, the server sends the whole HTML page.

This makes the initial loading of the site faster and also browsers don't have to wait for the Javascript files to load to execute the website's content.

Pros of using SSR

  • SSR improves website performance as it reduces the time browser has to spend rendering the page.

  • A fully rendered page leads to better search engine optimization(SEO).

  • A fully rendered page makes the website more accessible by providing content to slower internet users.

  • SSR relies on a single codebase thus it's easier to maintain and website's code.

How Server Side Rendering improves Search Engine Optimization (SEO)?

In server-side rendering, the browser received the fully rendered page, without having to wait for Javascript files to load. It makes the website easy to crawl for Google crawlers and also indexes the website's content. It improves ranking in search engine result pages.

Which frameworks should you use for Server Side Rendering?

NextJS offers built-in server-side rendering. In other frameworks such as ReactJS, AngularJs, VueJS, ExpressJS, and Flask, built-in SSR is not provided. For SSR in this framework, we have to use third-party libraries.

Cons of using SSR

  • SSR needs more processing power which can lead to additional load on the servers.

  • Implementation of SSR requires a complex development process and a deeper understanding of SSR and architecture.

  • It limits interactivity and dynamic content that can be added to the website.

  • Caching is difficult in SSR because dynamic content is generated on the server.

  • If there are differences in the rendering of HTML and Javascript between the server and client environment then it can lead to an inconsistent user experience.

When to use and when to avoid Server Side Rendering?

Conclusion

The usage of server-side rendering depends on the specific needs of the projects. It's good to use for blogging websites or news websites as it relies on SEO performance. It is also good for websites where users may experience a slower internet connection as it pre-renders the HTML pages. Sites with SSR are not recommended to streaming websites, as they require more processing power and depend on real-time content. Websites with complex architecture, such as microservices or multi-server setups, may not be well-suited to server-side rendering.

Developers should weigh all the pros and cons before proceeding towards the development.