What is a service worker

Service workers are at the base of all PWAs, and allow us to intercept network requests and implement the appropriate caching strategy for these calls.


Definition

A service worker is a special kind of web worker, but there is a subtle difference between them:

A service worker is a JavaScript file acting as a proxy between our web application and the network.

Web workers are scripts with a generic purpose, commonly used to lift heavy tasks from the main thread and run them in a different context.

A service worker (in short, SW) can intercept HTTP requests and serve the responses from the network or a local cache, according to which caching ...