Skip to content
Performance & Accessibility

Service Worker Caching Strategies: The Decisions That Matter

Patterns for deciding what a service worker serves from cache and what it fetches from the network.

MediaScaleUp Editorial Team 2 min read 15 views
Service Worker Caching Strategies: The Decisions That Matter

Where most projects go wrong

The usual mistakes:

  • Caching HTML indefinitely
  • One strategy for everything
  • Service workers that never update
  • Caches that grow without limits

What good looks like instead

  • Choose a strategy per resource type
  • Serve fingerprinted assets cache first
  • Use network first for HTML that changes
  • Clean up old caches on service worker activation
  • Test update behavior after deployments
What to do and what to avoid with service worker caching strategies, side by side
Good practice against the usual mistakes, from the sources listed below.

Why it matters

The right strategy per resource type makes repeat visits fast and offline use possible, while the wrong one serves stale content.

The specs that matter

Published figures for Service Worker Caching Strategies
MeasureFigure
Cache firstsuits versioned static assets
Network firstsuits content that changes frequently
Stale while revalidateserves cache immediately and updates in the background
Versioningold caches must be cleaned up on activation

Knowing when to hand it over

Tip: Bring in help when offline support or repeat-visit speed matters.

Where this comes from

The figures and practices above come from the sources listed.

Working on something like this?

We take on Performance & Accessibility work for teams who want it done once, properly. Tell us what you are building and we will tell you honestly whether we are the right studio for it. Start a project.

Where to go next

Spotted something wrong? Report an error on this page. We correct on the page and say what changed.

All services

The work behind this article, and what it costs.

MediaScaleUp Editorial Team

Articles here are researched, written and checked by the MediaScaleUp studio team before they are published, and dated when they are reviewed.

Keep reading

More in Performance & Accessibility