Search code examples
javascriptprogressive-web-apps

Periodic background sync: multiple registrations with different tags


I've been using PBS for a while, with a single tag, and it works as expected. My main source of information is this article. However, I may need to register multiple PBS with different tags and I'm a little confused about it. So let's say that I have a web application that can be installed as PWA and I register multiple periodic background sync with different tags, at different times and with different intervals.

How does the browser manage that?

Will all registered PBS events be triggered at the same time, like a single PBS event with all the registered tags?

Or each tag will have its own periodic sync event, given they have been registered at different times and with different intervals?


Solution

  • Some of those behaviors are not covered explicitly by the specification, so in practice, different browsers that support Periodic Background Sync might implement them differently, and the same browser might vary in implementation across different operating systems.

    Generally speaking, my experience with Chrome has been that it attempts to minimize the number of times a given service worker has to be woken up via events like Periodic Background Sync, so I would imagine that multiple tags would result in multiple events that are each fired within a very short interval.

    Based on the specification, you'll get one separate event fired per tag, rather than a single event that represents multiple tags.