ServiceWorkerGlobalScope: periodicsync event

Draft

This page is not complete.

The periodicsync event of the ServiceWorkerGlobalScope interface is fired at timed intervals, specified when registering a PeriodicSyncManager.

Bubbles No
Cancelable No
Interface PeriodicSyncEvent
Event handler property ServiceWorkerGlobalScope.onperiodicsync

Examples

The following example shows how to respond to a periodic sync event in the service worker.

self.addEventListener('periodicsync', event => {
  if (event.tag == 'get-latest-news') {
    event.waitUntil(fetchAndCacheLatestNews());
  }
});

You can also set up the event handler using the ServiceWorkerGlobalScope.onperiodicsync property:

self.onperiodicsync = (event) => {
  ...
};

Specifications

Specification Status Comment
Web Periodic Background Synchronization
The definition of 'periodicsync' in that specification.
Working Draft Initial definition.

Browser compatibility

No compatibility data found for api.ServiceWorkerGlobalScope.periodicsync_event.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

See also