service-worker

Installation
SKILL.md

Service Worker

Overview

Service workers are event-driven scripts that run in a separate thread from the main page, intercepting network requests, managing caches, and enabling offline functionality. Workbox v7.4 (maintained by the Chrome Aurora team) provides a production-ready abstraction over the low-level Cache API and fetch event handling.

When to use: Progressive web apps needing offline support, apps requiring push notifications, background data synchronization, app shell caching, network request optimization with static routing.

When NOT to use: Simple static sites served from a CDN, server-rendered apps with no offline requirements, apps where stale data is unacceptable (use network-only), prototypes where caching complexity is premature.

Quick Reference

Pattern API / Tool Key Points
Registration navigator.serviceWorker.register() Register in window context, scope defaults to path
Precaching workbox-precaching Revision-hashed app shell, injected at build time
Cache-first CacheFirst strategy Static assets, fonts, images
Network-first NetworkFirst strategy API responses needing freshness
Stale-while-revalidate StaleWhileRevalidate strategy Balance between speed and freshness
Related skills
Installs
39
GitHub Stars
11
First Seen
Feb 24, 2026