juniorPWA
What is a Service Worker in PWA?
Updated May 17, 2026
Short answer
A Service Worker is a background script that enables offline capabilities and caching.
Deep explanation
Service Workers act as a proxy between the browser and network. They intercept requests, manage caching, and enable features like offline support, push notifications, and background sync.
Real-world example
Offline reading in news apps is powered by Service Workers.
Common mistakes
- Confusing Service Workers with regular JavaScript running in the main thread.
Follow-up questions
- Can Service Workers access DOM?
- How are Service Workers updated?