Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Data Fetching (Mid-Level)

40%
Nuxt & Universal SSR (50 Qs)•Part 2: Core Architecture & Data Fetching (Mid-Level)

How does SWR / ISR work in Nuxt 3?

senior LevelCode ExampleSystem DesignApache KafkaVue & Nuxt

In Simple Words: SWR (Stale-While-Revalidate) and ISR (Incremental Static Regeneration) cache the generated HTML or JSON at the edge server/CDN.

  • When User 1 requests a route, the server renders and caches it.
  • Subsequent users receive the cached version instantly (sub-millisecond latency).
  • Once the cache TTL expires (e.g., 60 seconds), the next request still serves the stale cache instantly, while Nitro triggers an asynchronous background revalidation to generate fresh HTML for future visitors.
typescript
// nuxt.config.ts
export default defineNuxtConfig({
  routeRules: {
    '/products/**': { swr: 60 } // Cache at edge for 60 seconds
  }
});