What problem does it solve?
Service Worker misconfiguration causes cache pollution, stale API data, white screens, and login failures in production. This Skill provides the exact caching rules, file ownership map, and rollback procedures for the Magic Web Service Worker implementation so changes stay safe and verifiable.
Core Features & Use Cases
- Cache Partitioning Rules: Defines CacheFirst buckets for hashed static assets, images, and fixed-path WASM/WebWorker resources, with explicit runtime cache exclusions.
- Read-Only API Caching: Implements Stale-While-Revalidate for whitelisted GET endpoints with three-level request overrides via swCacheOption and strict response envelope validation (json.code === 1000).
- Emergency Rollback SOPs: Server-side takeover of /sw.js using MAGIC_SW_MODE=kill|off and MAGIC_SW_CLEAR_CACHES to unregister workers or evict specific cache buckets.
- Use Case: When adding a new settings API to the cache whitelist, follow SOP A to update CACHEABLE_API_RULES in sw-constants.ts, register the interceptor, then run the unit test trio and production build before submitting.
Quick Start
Ask the agent to add a new read-only API endpoint to the Service Worker cache whitelist and verify it with the required unit tests and production build.