When a user requests some web page content—if it’s been a while since its last update—ISR springs into action to swiftly regenerate the page with fresh data and return it to the client. What an innovative way of keeping your site fresh and relevant!
For example, consider a platform where service prices change frequently. With ISR, only the service pages needing updates are regenerated, ensuring you always see up-to-date prices information.
On-demand updates
High scalability
A mix between SSR and SSG
Difficult to implement
Hard to find the right regeneration criteria
Increased complexity
Focus on critical paths and sections: Get the most out of ISR by prioritizing the pages or sections of your website that require frequent updates or personalized content.
Optimize revalidation intervals: Fine-tune the revalidation intervals for ISR to balance between serving fresh content and minimizing server load, considering factors like content volatility and user traffic patterns.
Implement content fallback strategies: Establish fallback mechanisms to serve stale content during regeneration periods, ensuring a smooth user experience even when fresh data is unavailable.
Set cache control headers: Configure cache control headers to instruct clients on how to locally cache ISR responses to avoid triggering regenerations with unnecessary requests.
Client-Side Rendering (CSR) is a web development approach where the rendering of web pages occurs dynamically on the user's device rather than on the server.
Assume the Web is an interactive canvas. You can think of CSR as the artist who sketches the details directly on your screen . Now, imagine walking into an art gallery where each painting is blank upon arrival. As you approach a painting, the details gradually emerge, meticulously crafted by the artist right before your eyes. Similarly, in CSR, the webpage arrives as a blank canvas, and your browser uses JavaScript to fetch data and construct the visual elements on the fly.
For instance, consider a Single Page Application (SPA) that relies on CSR, such as a social media platform. If you visit it—instead of receiving fully rendered pages from the server—your browser receives empty pages with involving a JavaScript bundle. The browser executes the JS code, dynamically generates the DOM, and retrieves new content as you navigate the app.
Enhanced interactivity
Improved reactivity
Rich UI
Resources can be requested onlt when they need to be rendered
Resource-intensive rendering tasks that take time
SEO challenges
Requires JavaScript enabled
Minimize bundle size: Improve load times and reduce bandwidth consumption by optimizing the size of client-side bundles with tree shaking, code minification, and code splitting in small chunks.
Implement lazy loading: Defer the loading of non-essential resources until they’re needed, reducing initial page load times and conserving bandwidth.
Cache assets strategically: Leverage browser caching to cache static assets and API responses like a boss.
Optimize client-server communication: Streamline client-server communication by minimizing unnecessary requests and compressing JSON data payloads.
Ensure browser compatibility: Test your application across different browsers and devices to ensure consistent performance, responsiveness, and functionality.
Thought of SSR, SSG, ISR, and CSR as mutually exclusive rendering approaches? Think again!In reality, all four rendering methods can be employed together, each on different areas of the same site:
Server-Side Rendering (SSR): Pages in the e-commerce section of the site.
Incremental Static Regeneration (ISR): Pages in the blog section of the site.
Static-Site Generation (SSG): Home page, landing pages, terms and conditions page, and privacy policy page.
Client-Side Rendering (CSR): Back-office SPA platform.
Moreover, even within a server-generated page, certain sections may require client-side rendering and JavaScript execution. Thus, the landscape of page rendering is far more diverse than you may have thought!
Confront the four different rendering approaches explored here in the final SSR vs SSG vs ISR vs CSR summary table below.
Criteria | SSR | SSG | ISR | CSR |
---|---|---|---|---|
Rendering Location | Server | Server | Server | Client |
Rendering Time | On-request arrival | At build time | At build time + On-request arrival updates | On receiving page in the browser |
Dynamic Updates | ✅ | ❌ | ✅ | ✅ |
SEO Friendly | ✅ | ✅ | ✅ | ❌ |
JS Execution | Not Required | Not Required | Not Required | Required |