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.
On this page
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
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
| Measure | Figure |
|---|---|
| Cache first | suits versioned static assets |
| Network first | suits content that changes frequently |
| Stale while revalidate | serves cache immediately and updates in the background |
| Versioning | old 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
- MDN Web Docs — Service Worker API
- web.dev — Offline
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.