Skip to content

FlashcardNot attempted

Service worker caching strategies

Recall it before you reveal

Name the main service-worker caching strategies and when to use each.

Space to reveal
Show answer & explanation
  • Cache first: serve from the cache and fall back to the network. For versioned static assets (hashed JS/CSS, fonts, icons).
  • Network first: try the network and fall back to the cache when offline. For HTML and API data that should be fresh.
  • Stale-while-revalidate: serve the cached copy immediately while updating it in the background. For avatars and feeds where slightly old is fine.
  • Network only / cache only: payments and analytics, versus a pre-cached offline page.

Remember the quota (navigator.storage.estimate()), to clean old caches on activate, and that Workbox implements all of these.