[Beacon] Interaction with Service Worker

It's not immediately obvious how the beacons should be "seen" by Service Workers and how UAs should interact with them, so it'd be nice if the spec gave some guidance about this.

My suggestion is:

The Service Worker should be able to intercept beacon requests. The implementation of service worker should forward these requests immediately. Even when Service Worker is used, the UA should still be in charge of error handling and when it decides to retry sending the beacon it should make another request.

Basically, just passing the request through should be an ideal implementation of the service worker.

The alternative would be to make Service Worker responsible for queueing and retrying beacon requests, which may seem like a good idea at first. However, IMHO, that would be a sharp jump in difficulty for authors:

- authors would have to reinvent UA's logic for managing network traffic/priorities and strategy for optimal use of cellular radio power. That's currently not even possible, and even if it was, that's a pretty complex problem to throw at authors.

- authors may use Service Workers for other reasons than interception of beacons, so reliability of sendBeacon should not be negatively affected by mere presence of a Service Worker.

- having simple, useful default behavior without reliance on a service worker is very useful, and doesn't stop authors from implementing additional logic in the SW if they wish.

regards, Kornel

Received on Saturday, 17 May 2014 00:14:35 UTC