Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Error’d: Pickup Sticklers

      September 27, 2025

      From Prompt To Partner: Designing Your Custom AI Assistant

      September 27, 2025

      Microsoft unveils reimagined Marketplace for cloud solutions, AI apps, and more

      September 27, 2025

      Design Dialects: Breaking the Rules, Not the System

      September 27, 2025

      Building personal apps with open source and AI

      September 12, 2025

      What Can We Actually Do With corner-shape?

      September 12, 2025

      Craft, Clarity, and Care: The Story and Work of Mengchu Yao

      September 12, 2025

      Cailabs secures €57M to accelerate growth and industrial scale-up

      September 12, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025
      Recent

      Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

      September 28, 2025

      Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

      September 28, 2025

      The first browser with JavaScript landed 30 years ago

      September 27, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured
      Recent
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Deconstructing the Request Lifecycle in Sitecore Headless – Part 2: SSG and ISR Modes in Next.js

    Deconstructing the Request Lifecycle in Sitecore Headless – Part 2: SSG and ISR Modes in Next.js

    August 20, 2025

    In my previous post, we explored the request lifecycle in a Sitecore headless application using Next.js, focusing on how Server Side Rendering (SSR) works in tandem with Sitecore’s Layout Service and the Next.js middleware layer.. But that’s only one part of the story.

    This follow-up post dives into Static Site Generation (SSG) and Incremental Static Regeneration (ISR) – two powerful rendering modes offered by Next.js that can significantly boost performance and scalability when used appropriately in headless Sitecore applications.

    Why SSG and ISR Matter?

    In Sitecore XM Cloud-based headless implementations, choosing the right rendering strategy is crucial for balancing performance, scalability, and content freshness. Static Site Generation (SSG) pre-renders pages at build time, producing static HTML that can be instantly served via a CDN. This significantly reduces time-to-first-byte (TTFB), minimizes server load, and is ideal for stable content like landing pages, blogs, and listing pages.

    Incremental Static Regeneration (ISR) builds on SSG by allowing pages to be regenerated in the background after deployment, based on a configurable revalidation interval. This means you can serve static content with the performance benefits of SSG, while still reflecting updates without triggering a full site rebuild.

    These strategies are especially effective in Sitecore environments where:

    • Most pages are relatively static and don’t require real-time personalization.
    • Content updates are frequent but don’t demand immediate global propagation.
    • Selective regeneration is acceptable, enabling efficient publishing workflows.

    For Sitecore headless implementations, understanding when and how to use these strategies is key to delivering scalable, performant experiences without compromising on content freshness.

    SSG with Sitecore JSS: The Request Lifecycle

    In a Static Site Generation (SSG) setup, the request lifecycle transitions from being runtime-driven (like SSR) to being build-time-driven. This fundamentally alters how Sitecore, Next.js, and the JSS application work together to produce HTML. Here’s how the lifecycle unfolds in the context of Sitecore JSS with Next.js:

    1. Build-Time Route Generation with getStaticPaths

    At build time, Next.js executes the getStaticPaths function to determine which routes (i.e., Sitecore content pages) should be statically pre-rendered. This typically involves calling Sitecore’s Sitemap Service or querying layout paths via GraphQL or REST.

    2. Layout Data Fetching with getStaticProps

    For every path returned by getStaticPaths, Next.js runs getStaticProps to fetch the corresponding layout data from Sitecore. This data is fetched via: Sitecore Layout Service REST endpoint, or Experience Edge GraphQL endpoint

    At this stage:

    • Sitecore’s middleware is not executed.
    • There is no personalization, since requests are not user-specific.
    • The component factory in the JSS app maps layout JSON to UI components and renders them to static HTML.

    3. Static HTML Generation

    Next.js compiles the entire page into an HTML file using:

    • The Layout JSON from Sitecore.
    • Mapped UI components from the JSS component factory.
    • Placeholder content populated during build

    This results in fully static HTML output that represents the Sitecore page as it existed at build time.

    4. Deployment & Delivery via CDN

    Once built, these static HTML files are deployed to a CDN or static hosting platform (e.g., Vercel, Netlify), enabling:

    • Sub-second load times as no runtime rendering is required.
    • Massively scalable delivery.

    5. Runtime Request Handling

    When a user requests a statically generated page:

    • CDN Cache Hit: The CDN serves the pre-built HTML directly from cache
    • No Server Processing: No server-side computation occurs
    • Client-Side Hydration: React hydrates the static HTML, making it interactive
    • Instant Load: Users experience near-instantaneous page loads

    Incremental Static Regeneration (ISR): The Best of Both Worlds

    While SSG provides excellent performance, it has a critical limitation: content becomes stale immediately after build. ISR addresses this by enabling selective page regeneration in the background, maintaining static performance while ensuring content freshness.

    ISR Request Lifecycle in Sitecore JSS Applications

    1. Initial Request (Cached Response)

    When a user requests an ISR-enabled page:

    export const getStaticProps: GetStaticProps = async (context) => {
      const layoutData = await fetchLayoutData(context.params?.path);
      
      return {
        props: { layoutData },
        revalidate: 3600, // Revalidate every hour
      };
    };
    • Next.js checks if a static version exists and is within the revalidation window
    • If valid, the cached static HTML is served immediately
    • If the cache is stale (beyond revalidation time), Next.js triggers background regeneration

    2. Background Regeneration Process

    When regeneration is triggered:

    1. Next.js makes a fresh API call to Sitecore’s Layout Service or GraphQL endpoint
    2. Sitecore resolves the current item, applies any layout changes, and returns updated JSON
    3. The JSS component factory processes the new layout data
    4. The newly rendered HTML replaces the cached version
    5. Updated content propagates across the CDN network

    3. Subsequent Requests

    After regeneration completes:

    • New requests serve the updated static content
    • The cycle repeats based on the revalidation interval
    • Users always receive static performance, even during regeneration

    Best Practices for Sitecore SSG/ISR Implementation

    When implementing SSG and ISR in Sitecore headless applications, align your rendering strategy with content characteristics: use SSG for truly static pages like landing pages, ISR for semi-dynamic content such as blogs and product catalogs with appropriate revalidation intervals (5 minutes for news, 30 minutes for blogs, 1 hour for products), and continue using SSR for personalized experiences. Focus on selective pre-rendering by only building high-traffic, SEO-critical, and core user journey pages at build time while using fallback strategies for less critical content.

    Conclusion: Choosing the Right Strategy

    The choice between SSR, SSG, and ISR isn’t binary – modern Sitecore headless applications often employ a hybrid approach:

    • SSG for truly static content that rarely changes
    • ISR for content that updates periodically but doesn’t require real-time freshness
    • SSR for personalized experiences and rapidly changing content

    By understanding the request lifecycle for each rendering strategy, you can architect Sitecore headless solutions that deliver exceptional performance while maintaining content flexibility. The key is aligning your technical approach with your content strategy and user experience requirements. So, choose your rendering strategy wisely!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleSusan Etlinger, AI Analyst and Industry Watcher on Building Trust
    Next Article How to Set Up Firebase Crashlytics in a Flutter App (iOS and Android)

    Related Posts

    Development

    Using phpinfo() to Debug Common and Not-so-Common PHP Errors and Warnings

    September 28, 2025
    Development

    Mastering PHP File Uploads: A Guide to php.ini Settings and Code Examples

    September 28, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    Google Researchers Introduced LSM-2 with Adaptive and Inherited Masking (AIM): Enabling Direct Learning from Incomplete Wearable Data

    Machine Learning

    What’s the most pointless trend in modern web design?

    Web Development

    Discovering novel algorithms with AlphaTensor

    Artificial Intelligence

    Do Large Language Models Have an English Accent? Evaluating and Improving the Naturalness of Multilingual LLMs

    Machine Learning

    Highlights

    Chaos Testing Explained

    April 17, 2025

    Modern software systems are highly interconnected and increasingly complex bringing with them a greater risk of unexpected failures. In a world where even brief downtime can result in significant financial loss, system outages have evolved from minor annoyances to critical business threats. While traditional testing helps catch known issues, it often falls short when it
    The post Chaos Testing Explained appeared first on Codoid.

    How we’re supporting better tropical cyclone prediction with AI

    June 12, 2025

    Smashing Security podcast #431: How to mine millions without paying the bill

    August 20, 2025

    Amazon Strands Agents SDK: A technical deep dive into agent architectures and observability

    July 31, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.