Lädt...


🔧 A Deep dive into CSR, SSR, SSG and ISR


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

The evolution of the web has given rise to many innovative ways through which servers render and deliver web pages to the browser. some of which include server-side rendering(SSR), client-side rendering(CSR), static site generation(SSG), and incremental Static regeneration/revalidation(SSR). While most of these techniques have brought immense improvement in website load/delivery speed, they also have their use cases, pros, and cons. In this article, we dive a little bit deeper, taking a behind-the-scenes look at how these techniques work and when to use them.

Client-side rendering (CSR)

With client-side rendering, when a request is made to the server, the server responds with a blank HTML file and a javascript bundle. the javascript now builds the Dom(HTML elements) from scratch based on some virtual Dom(React virtual Dom) in a case where the app is built with React. hence depending on the bundle size returned to the browser, the user usually will see a blank screen for some seconds before the website information is then displayed.

steps involved in client-side rendering

  1. The user makes a request to the server
  2. The server returns a blank HTML page
  3. The browser fetches and downloads the JS bundle
  4. JS constructs HTML UI and makes it interactive(attaches necessary event handlers)
  5. Any request to 3rd party APIs are made
  6. Users can now fully interact with the web page

When to use client-side rendering

Client-side rendering is best used in web applications with large complex features and pages.

Pros

  • Reduced server-side workload
  • Reduced server cost
  • A better client experience

Cons

  • Poor SEO, since the initial page sent to the browser, is empty, web crawlers can't index the content of the page
  • Slow initial load since the dom is being constructed on the client side.

Server-side rendering(SSR)

With Server-side rendering, when a request is made to the server for a page, the server fetches relevant data for that page from the backend, constructs the full HTML page, and sends it back to the browser which will now become visible.

Note: even if javascript is disabled in our browser, we still see the full page, but can't interact with it.

Hence with server-side rendering, we construct the full HTML page on the server and return it to the browser.

When to use server-side rendering

SSR can be used on websites in which SEO is crucial. or in situations where each user has unique content shown on the initial load

Pros

  • Easy indexing by search engines
  • Fast load times especially in case of a slow connection

Cons

  • High server load, since the server has to build the page on every request
  • Slower transition between pages in the application

Static site generation(SSG)

with SSG, the server builds our website page together with its static assets once and serves it on a CDN(content delivery network). any subsequent request for a web page is served from the CDN. In SSG, pages are usually generated during application build time

When to use server-side generation

SSG can be used for websites whose content does change very often e.g blogs

Pros

  • High-performance thanks to CDN caching
  • The static HTML page will always be served even if the backend is down

Cons

  • The content of the page served by the CDN can easily get outdated in case of rapidly changing content.

Incremental static regeneration(ISR)

This concept is mostly popular with Nextjs. ISR is very similar to SSG, they work basically the same, but ISR goes an extra step. After the static page is served on the CDN, and after some interval, the page on the CDN is then invalidated and a new version of the page is regenerated with fresh data. with this, we can use SSG with data that is frequently changing.

when to use incremental static regeneration
we can use ISR with websites where we want to get fresh updates delivered to the customer per page basis without having to redeploy the site and with the benefits of SSG.

Pros

  • Less server load
  • Content delivery is very fast
  • Rebuilding/deploying the website to display fresh content is not needed.

Cons

  • Might need extra configuring steps

These page rendering techniques are used in different situations and have several pros and cons. Most modern applications will often make use of more than one e.g SSG + CSR or ISR + CSR.combining these techniques provide an amazing way of getting the best of both worlds, be it website performance or SEO.

...

🔧 A Deep dive into CSR, SSR, SSG and ISR


📈 115.45 Punkte
🔧 Programmierung

🔧 How to understand the concepts of Next.js such as CSR , SSR, SSG, ISR, RSC, SPA, and Streaming SSR?


📈 109.08 Punkte
🔧 Programmierung

🔧 The Ultimate Guide to Web Rendering: Improving Performance with CSR, SSR, SSG, and ISR


📈 90.36 Punkte
🔧 Programmierung

🔧 Exploring Web Rendering Strategies: A Deep Dive into CSR, SSR, SSG and ISG


📈 89.04 Punkte
🔧 Programmierung

🔧 The difference of writing CSR, SSR and SSG in Next.js App Router and Page Router.


📈 65.62 Punkte
🔧 Programmierung

🔧 CSR vs SSR vs SSG


📈 62.29 Punkte
🔧 Programmierung

🔧 What is the difference between SSR, ISR, SSS 👀


📈 45.13 Punkte
🔧 Programmierung

🔧 What are Hydration, CSR, and SSR in React and NextJS?


📈 43.68 Punkte
🔧 Programmierung

🔧 What is Server Side Rendering (SSR) and Static Site Generation (SSG)?


📈 42.31 Punkte
🔧 Programmierung

🔧 Understanding SSR and SSG in Modern Web Development


📈 42.31 Punkte
🔧 Programmierung

🔧 Basic Differences Between SSR and SSG


📈 42.31 Punkte
🔧 Programmierung

🔧 ASTRO JS | P2 | SSG and SSR


📈 42.31 Punkte
🔧 Programmierung

🔧 Understanding the difference between Static Site Generation (SSG) and Server Side Rendering (SSR)


📈 42.31 Punkte
🔧 Programmierung

🔧 Mastering Next.js: My Journey from SSG to SSR Through Trial and Error


📈 42.31 Punkte
🔧 Programmierung

🔧 The Junior Developer's Complete Guide to SSR, SSG and SPA


📈 42.31 Punkte
🔧 Programmierung

🔧 🔍 SSR vs. CSR: Understanding the Differences and When to Use Them


📈 42.02 Punkte
🔧 Programmierung

🔧 Angular 17, does SSR/SSG really work?


📈 40.65 Punkte
🔧 Programmierung

🔧 Understanding the Differences: Server Side Rendering (SSR) vs Static Site Generation (SSG) in Next.js


📈 40.65 Punkte
🔧 Programmierung

🔧 SSR 🆚 SSG: A Game-Changer for Your Web App ☄️


📈 40.65 Punkte
🔧 Programmierung

🔧 SSR 🆚 SSG: A Game-Changer for Your Web App ☄️


📈 40.65 Punkte
🔧 Programmierung

🔧 SSG vs SSR


📈 40.65 Punkte
🔧 Programmierung

🔧 Server Side Rendering in JavaScript – SSR vs CSR Explained


📈 40.36 Punkte
🔧 Programmierung

🔧 Understanding Server-Side Rendering (SSR) vs. Client-Side Rendering (CSR)


📈 40.36 Punkte
🔧 Programmierung

🔧 Server-Side Rendering (SSR) vs. Client-Side Rendering (CSR): The Fascinating World of Page Rendering


📈 40.36 Punkte
🔧 Programmierung

🔧 Client-Side Rendering (CSR) Vs Server-Side Rendering (SSR)


📈 40.36 Punkte
🔧 Programmierung

🔧 CSR ve SSR


📈 40.36 Punkte
🔧 Programmierung

🔧 Client Side Rendering (CSR) vs Server Side Rendering (SSR): Simplified Story


📈 40.36 Punkte
🔧 Programmierung

🔧 Episode 24/27: SSR Hybrid Rendering & Full SSR Guide


📈 37.43 Punkte
🔧 Programmierung

🔧 A Deep Dive Into Recommendation Algorithms With Netflix Case Study and NVIDIA Deep Learning Technology


📈 35.08 Punkte
🔧 Programmierung

🎥 Deep dive into Flutter deep linking


📈 33.41 Punkte
🎥 Video | Youtube

🔧 Deep Dive into apple-app-site-association file: Enhancing Deep Linking on iOS


📈 33.41 Punkte
🔧 Programmierung

🔧 Deep Dive into apple-app-site-association file: Enhancing Deep Linking on iOS


📈 33.41 Punkte
🔧 Programmierung

🔧 Deep Dive Into AI’s Inheritance Into Software Development


📈 31.1 Punkte
🔧 Programmierung

matomo