One-off Sync vs Periodic Background Sync
You'll learn: How to distinguish between one-time Background Sync for immediate retries and Periodic Background Sync for scheduled, recurring updates.
Two Flavors of Background Synchronization
You've been working with Background Sync, which fires once when connectivity returns after a failed request. Think of it like leaving a note for someone: "When you get a chance, please send this message I couldn't deliver." It's a one-off task.
Periodic Background Sync is fundamentally different. Instead of waiting for a specific failure, it runs on a schedule in the background, even when your app isn't open. Imagine a newspaper delivery: it arrives daily whether you requested today's edition or not. This pattern handles recurring data updates like syncing news feeds, refreshing content, or pulling notifications.
Key Differences
One-off Background Sync:
- Triggered by your code registering a sync tag
- Fires once when online connectivity resumes
- Perfect for retrying failed POST requests or form submissions
- Already covered in your previous lessons
Periodic Background Sync:
- Runs at intervals determined by the browser (you suggest a minimum interval)
- Browser decides actual timing based on user engagement and device conditions
- Requires permission and user trust signals
- Ideal for keeping content fresh without user action
Use Case Examples
Use one-off sync when: submitting a purchase, posting a comment, updating profile settings.
Use periodic sync when: refreshing article feeds, checking for new messages, updating weather data, syncing calendar events.
The browser heavily restricts Periodic Background Sync—it won't run if the user rarely visits your site. This prevents abuse and respects battery life.
Key Takeaway: One-off Background Sync handles immediate retry-after-failure scenarios, while Periodic Background Sync maintains fresh content through scheduled updates, though with stricter browser controls.