Periodic background sync

Yesterday I wrote about how much I’d like to see silent push for the web:

I’d really like silent push for the web—the ability to update a cache with fresh content as soon as it’s published; that would be nifty! At the same time, I understand the concerns. It feels more powerful than other permission-based APIs like notifications.

Today, John Holt Ripley responded on Twitter:

hi there, just read your blog post about Silent Push for acthe web, and wondering if Periodic Background Sync would cover a few of those use cases?

Periodic background sync looks very interesting indeed!

It’s not the same as silent push. As the name suggests, this is about your service worker waking up periodically and potentially fetching (and caching) fresh content from the network. So the service worker is polling rather than receiving a push. But I’ll take it! It’s definitely close enough for the kind of use-cases I’ve been thinking about.

Interestingly, periodic background sync also ties into the other part of what I was writing about: permissions. I mentioned that adding a site the home screen could be interpreted as a signal to potentially allow more permissions (or at least allow prompts for more permissions).

Well, Chromium has a document outlining metrics for attempting to gauge site engagement. There’s some good thinking in there.

Responses

CSS-Tricks

Periodic background sync adactio.com/journal/16043 (Notes from @adactio) > It’s not the same as silent push. As the name suggests, this is about your service worker waking up periodically and potentially fetching (and caching) fresh content from the network.

# Posted by CSS-Tricks on Wednesday, October 30th, 2019 at 11:17pm

1 Like

# Liked by Clout chaser on Tuesday, October 29th, 2019 at 6:35pm

Related posts

Future Sync 2020

Questions and answers from the opening talk of an online conference.

Service workers in Samsung Internet browser

Samsung Internet browser doesn’t yet support asynchronous `waitUntil`, but that’s okay.

Web notifications on iOS

The number one feature request I have for mobile Safari is web notifications (even if I won’t personally use them).

Image previews with the FileReader API

Adding `alt` text to uploaded images.

Implementors

Different browser vendors have different priorities.

Related links

CSS-only chat

A truly monstrous async web chat using no JS whatsoever on the frontend.

This is …I mean …yes, but …it …I …

Tagged with

Send messages when you’re back online with Service Workers and Background Sync – Twilio Cloud Communications Blog

This example of using background sync looks like it’s specific to Twilio, but the breakdown of steps is broad enough to apply to many situations:

On the page we need to:

  1. Register a Service Worker
  2. Intercept the “submit” event for our message form
  3. Place the message details into IndexedDB, an in browser database
  4. Register the Service Worker to receive a “sync” event

Then, in the Service Worker we need to:

  1. Listen for sync events
  2. When a sync event is received, retrieve the messages from IndexedDB
  3. For each message, send a request to our server to send the message
  4. If the message is sent successfully, then remove the message from IndexedDB

And that’s it.

Tagged with

Enhancing a comment form: From basic to custom error message to BackgroundSync | justmarkup

This is a truly fantastic example of progressive enhancement applied to a form.

What I love about this is that it shows how progressive enhancement isn’t a binary on/off choice: there are layers and layers of enhancements here, from simple inline validation all the way to service workers and background sync, with many options in between.

Superb!

Tagged with

ServiceWorker: A Basic Guide to BackgroundSync

A nice introduction to using Service Workers to enable syncing in the background: when the user is offline, tasks get queued up and then when the user is back online, those tasks execute.

Tagged with

Local-first software: You own your data, in spite of the cloud

The cloud gives us collaboration, but old-fashioned apps give us ownership. Can’t we have the best of both worlds?

We would like both the convenient cross-device access and real-time collaboration provided by cloud apps, and also the personal ownership of your own data embodied by “old-fashioned” software.

This is a very in-depth look at the mindset and the challenges involved in building truly local-first software—something that Tantek has also been thinking about.

Tagged with

Previously on this day

7 years ago I wrote The meaning of AMP

Google’s alternative facts.

8 years ago I wrote Assumptions

Mobile hardware isn’t all that it seems.

14 years ago I wrote Listening

Music to build websites to.

18 years ago I wrote Laid low

Joyous guitar.

18 years ago I wrote Beautiful hackery

An API-driven text adventure, accessible train times and hackable URLs; oh, yes.

19 years ago I wrote Flickrism

Back in July, a Flickr member posted a photoset of a commercial he was working on. The spot involved the release of 250,000 superballs down a hill in San Francisco. Other Flickrites also documented the release.

20 years ago I wrote Anger is an energy

Last year BBC Radio One came to Brighton and organised a week of live music. This year, there’s no sign of auntie Beeb but local promoters have organised a week of music anyway.

22 years ago I wrote Apple - iMac

The deed is done. I just placed an order at the Apple store for a 17 inch iMac.