First of all, the service worker starts in another thread, and then in the main application. why you can use a service worker to increase productivity, because these operations will not affect the main application.
You can use localstorage to store data on the client side, but you cannot use it for offline caching. To get data from local storage, you first need to download a script that will try to access local storage.
SeriveWorkers are also stored in the client, and they can intercept the network layer. Thus, in your worker, you can decide whether you want to first load a specific route from the cache or try to request it from the network.
, : https://www.youtube.com/watch?v=OBfLvqA_E4A