Background Sync

The Background Sync API allows authorized web applications to not rely on having stable internet connection and defer sending the data to the moment the connection is available. The API is bound to the Service Worker, which is the code execution model that is separated from the owning web application. This allows the Background Sync to operate also after the application was closed.

As of Summer 2016, the API is implemented in Google Chrome only and the implementation is limited to one-off sync.

API glimpse

serviceWorkerRegistration.sync.register('syncTag')
Requests an one-off sync registration. Returns a Promise when the request has been accepted.
self.addEventListener('sync', listener)
An event fired within the Service Worker instance when there is a connection available and the synchronization is possible. The listener is expected to call event.waitUntil(promise) specifying a Promise that resolves when the sync handling is completed.
serviceWorkerRegistration.periodicSync.register(options)
Requests a periodic sync registration. Returns a Promise when the request has been accepted. This
self.addEventListener('periodicSync', listener)
An event fired within the Service Worker instance periodically, according to the registration optios, only when there is a connection available and the synchronization is possible. The listener is expected to call event.waitUntil(promise) specifying a Promise that resolves when the sync handling is completed.

Resources