tezvyn:

ISR: Static Speed for Dynamic Content

AI-drafted, machine-checkedSource: vercel.comadvanced

Incremental Static Regeneration (ISR) gives users a fast, static page while regenerating it in the background. It's ideal for e-commerce catalogs or blogs that update periodically.

WHY IT EXISTS Static sites are fast but can be stale. Server-rendered sites are fresh but slower. Incremental Static Regeneration (ISR) was created to solve this tradeoff, offering the performance of static content without requiring a full site rebuild for every minor data change.

THE MENTAL MODEL Think of ISR like a busy bakery that keeps a few popular cakes on display. When you buy one, you get it instantly. As you leave, the baker starts making a fresh one to replace it. You get your cake immediately, and the next customer gets a freshly baked one, with no one having to wait for it to be made from scratch.

HOW IT WORKS A user requests a page and is served a fast, cached static version from a CDN. If a pre-configured time interval has passed (or an API call triggers it), the server regenerates the page in the background. The next visitor gets this newly generated, fresh page. This is the 'stale-while-revalidate' caching strategy. Frameworks like Next.js and SvelteKit manage the underlying cache headers and regeneration logic for you.

WHEN TO USE IT ISR is perfect for content that updates periodically, not instantaneously. Key use cases include: first, large e-commerce catalogs with changing prices or stock; second, media sites where articles are updated in a headless CMS; and third, pages generated from discrete events like a git sync, not a continuous data stream.

WHEN NOT TO USE IT Do not use ISR for data that must be real-time. Because users are initially served a stale version while the new one generates, it's a poor fit for live dashboards, stock tickers, or chat applications. These require client-side fetching or server-side rendering on every single request.

ONE CANONICAL EXAMPLE A blog uses a headless CMS. At build time, you pre-render the most popular posts. When a visitor requests a less popular post, it's generated on-demand and cached. If an author updates a post, the CMS can send an API call to trigger revalidation. The next visitor gets the old cached page instantly, while the server generates the updated version in the background for all subsequent visitors.

Read the original → vercel.com

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.