What is a service worker?
A service worker is a browser worker responding to background events and mediating some page requests. It is not a permanently running server.
How it works and where it is used
1. How it works Registration, installation and activation precede fetch handling. The browser may stop the worker between events, so global memory is not durable storage. 2. Applications and examples Offline pages, asset caching and supported notifications are common uses. It can enhance a PWA but is not required for every site.
Limits and good practice
3. Limitations and security Bad cache rules can expose private content, serve stale pages or hide updates. HTTPS and correct scope matter; it does not repair app permissions. 4. Practical considerations Plan cache versions and cleanup, test offline and first-install behavior, and monitor activation and rollback.