Skip to content
TelegramWhatsApp

Dictionary

Service Workers

Service workers are JavaScript scripts that run in a separate thread from the main web page, acting as a programmable proxy between the browser and the network. They intercept every network request the page makes and can serve cached responses, fetch from the network, or return custom responses. This capability is the foundation for offline functionality in web applications.

Primary use cases include caching strategies for offline access, background data synchronization when connectivity is restored, and push notifications that work even when the browser tab is closed. Service workers are a core requirement for Progressive Web Apps and enable precaching critical assets during installation, serving stale content while revalidating in the background, and providing custom offline fallback pages. They operate on a lifecycle of installation, activation, and fetch handling, and require HTTPS origins for security. Frameworks like Workbox simplify implementation by providing pre-built caching strategies.