Chapter 9. Keeping your data synchronized

 

Chapter 8 talked about building resilient Progressive Web Apps (PWAs) that can handle flaky or intermittent network connections. In this chapter, we’ll take the offline web a step further and look at a new web API called BackgroundSync. This API allows users to queue data that needs to be sent to the server while a user is working offline, and then as soon as they’re online again, it sends the queued data to the server. This is useful for when you want to ensure that what your user submits to the server truly gets sent. To give you a quick example of this on a practical level, say a user needs to be able to edit the details of a blog post using a Content Management System (CMS). If the CMS uses Service Workers and BackgroundSync, the user can edit the contents of the blog post offline, and then the CMS will sync the results when the user is online again. This functionality allows users to work on the go, regardless of whether they’re connected to the internet.

By the end of the chapter, you’ll know a lot about BackgroundSync and how you can start using it in your web apps today. We’ll also dive into a soon-to-be-released feature called Periodic Sync that allows developers to schedule a sync for a predetermined time.

9.1. Understanding BackgroundSync

9.2. Notifying the user

9.3. Periodic synchronization

9.4. Summary

sitemap