Service worker in PWA
What is PWA
PWA stands for Progressive Web App. It was created by Google for describing its prospect of various application-like web experiences. This application contains many features of web pages including a control for connection, push notification, showing icons on home screen and many others.
Service Worker: who is it?
The most significant functions of the service worker are:
- providing people with the opportunity to have effective offline experience which a service worker creates;
- catching network requests;
- taking corresponding actions which depend on two factors: whether the network is available and whether updated assets reside on the server;
- allowing users to have access in order to push notifications and background sync APIs;
- controlling all network requests on a page.
So, a service worker can provide developers with different activities for intercepting requests, caching and forging responses. Moreover, developers can have even offline access to certain pages (for example, while confirming an order or showing information about an e-ticket). They also can benefit from a cached version when loading some resources takes too much time. Furthermore, service workers are responsible for background communication with different servers. It means some additional features such as task scheduler, push notifications, background sync and so on and so forth.