Service worker gives us access to the various features like push notifications and background sync and in future, they will provide geofencing.
They are created with a motive to provide to better offline experience to the people, intercepts the network request and take actions based on the network and update elements of the servers if it is required.
Few points to remember about service worker:
- They are a network proxy that is programmable too.
- They terminate themselves when not in use and restart whenever needed.
- They use promises extensively.
- They will make a website work offline and reduces the network requests too.
Service worker lifecycle is quite different from that of the webpage. Here are the few links where you can learn how to create service workers: