Please read Getting Started to start.
A service worker is a script that your browser runs in the background, separate from a web page, opening the door to features that don't need a web page or user interaction. Today, they already include features like push notifications and background sync. In the future, service workers will support other things like periodic sync or geofencing. The core feature discussed in this tutorial is the ability to intercept and handle network requests, including programmatically managing a cache of responses.
The reason this is such an exciting API is that it allows you to support offline experiences, giving developers complete control over the experience.
Before service worker, there was one other API that gave users an offline experience on the web called AppCache. There are a number of issues with the AppCache API that service workers were designed to avoid.
ref : https://developers.google.com/web/fundamentals/primers/service-workers/
-
The Service Worker API comes with a Cache interface, that lets you create stores of responses keyed by request. While this interface was intended for service workers it is actually exposed on the window, and can be accessed from anywhere in your scripts. The entry point is caches.
-
Do not let your visitor go because there is not internet connection. Offline first lets you to display web content even though no internet network is available.
-
Background sync is a new web API that lets you defer actions until the user has stable connectivity. This is useful for ensuring that whatever the user wants to send, is actually sent
-
Push notification provides a simple and effective way to re-engage with your users.
-
[WIP] Geofencing
Service worker only support localhost
and HTTPS
, you need some webserver to run in local. Here are some that we recomend :
We split the module into several directory, to get started please read README.md
we provide in each directory.