Service workers essentially act as proxy servers that sit between web applications, the browser, and the network (when available).
What they are used for
- enable the creation of effective offline experiences
- intercept network requests and take appropriate action based on whether the network is available
- update assets residing on the server
- allow access to push notifications and background sync APIs
A service worker is an event-driven worker registered against an origin and a path. It takes the form of a JavaScript file that can control the web-page/site that it is associated with.
Service workers only run over HTTPS, for security reasons.