Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Roadmap
  1. 1.HTTP/1.1 vs HTTP/2 vs HTTP/3 (QUIC)
  2. 2.TCP and TLS Handshakes: Connection Setup Costs
  3. 3.Browser Network Stack and Connection Pooling
  4. 4.GET vs POST and Idempotency in HTTP
  5. 5.The Critical Rendering Path (CRP)
  6. 6.DOM, CSSOM and the Render Tree
  7. 7.Layout, Paint and Compositing
  8. 8.Reflows and Repaints Explained
  9. 9.Event Loop: Call Stack, Task and Microtask Queues
  10. 10.Async JavaScript: Promises and async/await
  11. 11.Web Workers: Multi-threading in the Browser
  12. 12.Browser Storage: Cookies, Web Storage, IndexedDB
  13. 13.Client-Side Storage: Limits and Security Risks
  14. 14.Choosing the Right Client-Side Storage
  15. 15.HTTP Caching: Cache-Control, ETag, Last-Modified
  16. 16.Browser-Level Caching Mechanisms
  17. 17.Cache Invalidation for Frontend Apps
  18. 18.Structuring a Large Single-Page App
  19. 19.Component-Based Architecture Principles
  20. 20.Props, State and Component Lifecycle
  21. 21.Module Bundling Basics
  22. 22.Core Web Vitals: LCP, INP and CLS
  23. 23.FCP and Time to Interactive (TTI) Explained
  24. 24.Measuring Performance: Lighthouse and WebPageTest
  25. 25.Asset Compression and Minification Basics
  26. 26.What Is a CDN and How Does It Work?
  27. 27.CDN Benefits: Latency, Availability, Offload
  28. 28.CDN Cache Behavior and Invalidation
  29. 29.Global State vs Local Component State
  30. 30.State Patterns: Redux, Zustand and Context
  31. 31.Data Fetching: React Query and SWR
  32. 32.Immutable Data in Frontend State
  33. 33.SSR vs CSR: Rendering Trade-offs
  34. 34.Hydration and Time to First Byte (TTFB)
  35. 35.Static Site Generation (SSG) for Speed and SEO
  36. 36.Incremental Static Regeneration (ISR)
  37. 37.Micro-Frontends: Core Principles
  38. 38.Micro-Frontend Integration Strategies
  39. 39.Communication Between Micro-Frontends
  40. 40.Micro-Frontends: Pros and Cons for Large Teams
  41. 41.Real-Time: Polling, SSE and WebSockets
  42. 42.Real-Time Use Cases: Chat, Alerts, Live Data
  43. 43.Designing a Real-Time Data Flow
  44. 44.Scaling WebSocket Connections
  45. 45.Responsive Images: srcset, sizes and picture
  46. 46.Modern Image Formats: WebP, AVIF, JPEG XL
  47. 47.Lazy Loading Images and Videos
  48. 48.Video Streaming: HLS, DASH, Adaptive Bitrate
  49. 49.REST and GraphQL for Frontend Engineers
  50. 50.Batching, Throttling and Debouncing API Calls
  51. 51.Handling API Errors in the Frontend
  52. 52.Authentication Flows: OAuth and JWT
  53. 53.Global Error Boundaries in React
  54. 54.Error Reporting: Sentry and LogRocket
  55. 55.Graceful Degradation and Fallback UIs
  56. 56.Real User Monitoring (RUM)
  57. 57.CORS: Cross-Origin Resource Sharing
  58. 58.Preventing XSS (Cross-Site Scripting)
  59. 59.CSRF Protection for Frontend Apps
  60. 60.Content Security Policy (CSP)
  61. 61.Storing Auth Tokens: Cookies vs localStorage
  62. 62.PWA Manifest and Installability
  63. 63.Service Workers: Lifecycle and Caching Strategies
  64. 64.Offline Support and Background Sync
  65. 65.Push Notifications for Web Apps
  66. 66.Webpack vs Vite vs Parcel
  67. 67.Code Splitting, Tree Shaking, Asset Optimization
  68. 68.Module Resolution and Hot Module Replacement
  69. 69.Monorepo Tooling: Nx and Lerna
  70. 70.Atomic Design for Component Libraries
  71. 71.Theming and Customization in Design Systems
  72. 72.Accessibility in Component Libraries
  73. 73.Component Library Docs, Testing and Versioning
  74. 74.Publishing and Consuming a Component Library
  75. 75.Full-Text Search: Levenshtein and Fuzzy Matching
  76. 76.Indexing Large Datasets in the Browser
  77. 77.Search Performance: Debouncing and Web Workers
  78. 78.Integrating Backend Search Services
  79. 79.Choosing a Chart Library: D3, Chart.js, Recharts
  80. 80.Rendering Large Datasets: Canvas vs SVG
  81. 81.Interactive, Responsive Data Visualizations
  82. 82.Data Fetching and Aggregation for Dashboards
  83. 83.A/B Test Design and Rollout Strategies
  84. 84.Client-Side vs Server-Side A/B Testing
  85. 85.Feature Flags and Remote Configuration
  86. 86.Experiment Data Collection and Analytics
Frontend System Design Roadmap
35

Frontend System Design · Lesson 35 of 86 · 4 min

Static Site Generation (SSG) for Speed and SEO

This is your default answer for content-heavy sites. Know its trade-offs cold.

Static Site Generation (SSG) pre-renders your pages into static HTML files at build time. When a user requests a page, a server or CDN just sends the file. That’s it. No on-demand rendering, no database queries. This is the core of why it's so fast and why you need to be able to explain it.

The "Build Once, Serve Infinitely" Model

With SSG, the entire request-time workload is shifted to a one-time build step. Your CI/CD pipeline runs a command (next build, astro build, etc.), which fetches data, renders your components to HTML strings, and spits out a folder of static assets.

You deploy this folder to a CDN. Now, user requests are served from an edge location close to them, resulting in a minimal Time to First Byte (TTFB). The browser receives a complete HTML document immediately, so First Contentful Paint (FCP) and Largest Contentful Paint (LCP) are excellent. This is a direct path to good Core Web Vitals scores.

The process looks like this:

This model is simple and incredibly robust. If your build succeeds, your site is a collection of files that can be served by the simplest web server. High traffic is easily absorbed by the CDN.

Why SSG is the Easiest SEO Win

Search engine crawlers are simple clients. They want fast, linkable, fully-formed HTML. SSG delivers exactly that on every request.

Unlike client-side rendering, the crawler doesn't need to execute JavaScript to see your page content. It gets the same complete HTML file a user would, allowing for immediate and accurate indexing. Because SSG leads to top-tier performance metrics, it also directly satisfies Google's Core Web Vitals, which are a known ranking factor.

For any public-facing content—blogs, documentation, marketing pages, e-commerce product listings—SSG should be your starting point. It aligns perfectly with how search engines want to see the web.

Generating Pages from a Data Source

Most sites aren't just a few hand-written pages. You'll generate pages from a data source like a Headless CMS or a database. For this, you need to tell your framework which pages to build.

In Next.js, you do this with getStaticPaths (to list the pages) and getStaticProps (to get the data for each page).

This example generates a set of blog post pages at build time.

// pages/blog/[slug].tsx
import type { GetStaticProps, GetStaticPaths } from 'next';

// This function runs at build time to determine which routes to generate.
export const getStaticPaths: GetStaticPaths = async () => {
  // In a real app, fetch slugs from a CMS or database.
  const posts = [{ slug: 'intro-to-ssg' }, { slug: 'ssg-tradeoffs' }];

  const paths = posts.map((post) => ({
    params: { slug: post.slug },
  }));

  // { fallback: false } means any path not returned here will result in a 404.
  return { paths, fallback: false };
};

// For each path defined above, this function runs to fetch its specific data.
export const getStaticProps: GetStaticProps = async (context) => {
  const slug = context.params?.slug;
  // Fetch the full post content for the given slug from your data source.
  const post = await getPostFromDb(slug);

  if (!post) {
    return { notFound: true };
  }

  return {
    props: { post },
  };
};

// The component receives the fetched data as props.
export default function BlogPost({ post }) {
  return (
    <article>
      <h1>{post.title}</h1>
      <div>{post.content}</div>
    </article>
  );
}

The trap: This model implies a full site rebuild for any content change. For a site with 100,000 blog posts, getStaticPaths means your build process will fetch and render 100,000 pages. This can take a very long time, making it impossible to publish content updates quickly.

Know the Limits: Build Times and Stale Content

SSG is not a silver bullet. Knowing its limitations is more important in an interview than just listing its benefits. The primary trade-offs are build duration and content freshness.

Build Times: As mentioned, build time scales with the number of pages. A 45-minute build to fix a typo is not tenable. This is the single biggest operational headache of large-scale SSG.

Stale Content: The content on your site is only as fresh as your last deployment. If you run a news site and a story breaks, you can't wait for a long build to finish. You need a way to update content faster. A common pattern is using webhooks from your CMS to automatically trigger a new build and deployment, but this is still limited by the build duration.

No Personalized Content: The generated HTML is the same for every user. You cannot use SSG to pre-render a user's account dashboard or a personalized shopping cart. That content must be fetched client-side after the initial static page loads. This can lead to a flash of loading spinners or layout shifts, which harms the user experience.

In an interview, you'll be asked to defend your choice. The question is often "Why not SSG for everything?" Your answer should be about these trade-offs: build times for large sites, content freshness guarantees, and the inability to serve personalized content from the server.

Try it

Use a framework like Next.js or Astro to create two static blog post pages from a local JSON array. Implement the logic to define the routes (getStaticPaths) and pass the content to the component (getStaticProps). Run the build command and see the generated HTML files in the output directory.

Next: We'll look at how to get the benefits of static sites without the long build times and stale content problem by using Incremental Static Regeneration (ISR).

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Hydration and Time to First Byte (TTFB)

Next

Incremental Static Regeneration (ISR)