We’ve been working for a while on a Background Sync API, to allow websites with service workers schedule work to be performed later. As described in our explainer document:
If you write an email, instant message, or simply favourite a tweet, the application needs to communicate that data to the server. If that fails, either due to user connectivity, service availability or anything in-between, the app can store that action in some kind of ‘outbox’ for retry later.
Unfortunately, on the web, that outbox can only be processed while the site is displayed in a browsing context. This is particularly problematic on mobile, where browsing contexts are frequently shut down to free memory.
Native application platforms provide job scheduling APIs that enable developers to collaborate with the system to ensure low power usage and background-driven processing. The web platform needs capabilities like this too.
We propose a new API that extends Service Workers with a
sync event and an API for signalling the desire for this event to fire.
The explainer mentions both one-off syncs as well as periodic syncs, although initially we’d like to focus on just the first one of those, since we think it has much less privacy/security implications, and already addresses a lot of the use cases we’re interested in. We’ve started writing a spec for one-off syncs, and hope to further evolve/incubate this API in the WICG.