Prodtyping

The process on turning ideas into reality

December 25th 2018

What is a Service Worker?

A Service Worker is a script file that runs in the background. It acts as a proxy between a web page and the network and provides the ability to intercept, cache and modify networks requests. This ability gives developers the ability to create an offline-first experience for this web applications! Note that the use of a service worker is only available with HTTPS for security purposes. A service worker is considered a special kind of web worker written in JavaScript. It runs separately from the main thread so that computations can be done without affecting UI responsiveness. They can receive messages when they're not active because they run independently of the application. This means that they can work when the application is in the background or closed. Typically they are used as a caching layer to handle network requests, to cache content for use offline, and for push notifications. Service workers are a key part to powering progressive web applications because they provide a way to cache resources and do push notifications allowing for web applications to now have a native-like feel.