Periodic Background Sync Demo - Online PWA Feature
Register a periodic background sync to fetch fresh data even when the tab is closed. Understand the API and limits.
UD5 Toolkit
Register, test, and monitor Periodic Background Sync API for your PWA
Create a new periodic background sync task
One-click common sync configurations
self.addEventListener('periodicsync', (event) => {
console.log('[SW] Periodic Sync triggered:', event.tag);
if (event.tag === 'news-update') {
event.waitUntil(
fetch('/api/latest-news')
.then(res => res.json())
.then(data => {
// Cache or post message to clients
return clients.matchAll({ type: 'window' })
.then(clients => {
clients.forEach(client => {
client.postMessage({
type: 'SYNC_COMPLETE',
tag: event.tag,
data: data
});
});
});
})
.catch(err => console.error('[SW] Sync failed:', err))
);
}
// Handle other tags...
});
registration.periodicSync.register(tag, opts) | Register a new periodic sync with tag name and {minInterval} in ms. |
registration.periodicSync.unregister(tag) | Remove a previously registered periodic sync by tag name. |
registration.periodicSync.getTags() | Returns Promise<string[]> of all registered sync tag names. |
navigator.permissions.query({name:'periodic-background-sync'}) | Check permission state: granted, denied, or prompt. |
| Chrome minInterval (dev) | ~10 seconds on localhost with flags enabled. |
| Chrome minInterval (prod) | 12 hours (43,200,000 ms) minimum for installed PWAs. |
| Site Engagement | Chrome requires sufficient site engagement score for periodic sync to fire. |
Periodic Background Sync allows a PWA to periodically fetch fresh content in the background, even when the user isn't actively using the app. It's designed for regular updates like news feeds, weather data, or stock prices.
Background Sync (one-off sync) is different — it's designed for deferred actions. When a user performs an action while offline (like sending a message), Background Sync queues it and sends it when connectivity returns. Periodic Sync is time-based and recurring; Background Sync is connectivity-based and one-shot.
| Feature | Periodic Background Sync | Background Sync |
|---|---|---|
| Trigger | Time interval | Network recovery |
| Frequency | Recurring (min ~12h in prod) | One-shot per registration |
| Use Case | Content pre-caching | Offline action queue |
| PWA Required | Yes (installed) | No |
localhost for development).periodicsync event listener is required.periodic-background-sync permission must be granted (usually implicit upon PWA install).If your periodic sync isn't triggering, check these common issues:
window.matchMedia('(display-mode: standalone)').matches.chrome://site-engagement/ to check your site's score.self.addEventListener('periodicsync', ...).chrome://serviceworker-internals/ for more detailed debugging. Tip: In development (localhost), you can reduce minInterval to as low as ~10 seconds by enabling chrome://flags/#periodic-background-sync experimental features.
Periodic Background Sync excels in these scenarios:
Avoid using it for real-time critical data (use WebSockets) or very frequent updates (respect user's data and battery).
Yes! Periodic Background Sync works on Android devices with Chrome 80+ installed. The PWA must be added to the home screen.
On iOS, support is limited. As of 2025, Safari on iOS does not support the Periodic Background Sync API. PWAs on iOS have more restricted background capabilities. Consider using alternative strategies (like silent push notifications or Background Fetch API where available) for iOS users.
Always implement feature detection and provide graceful fallbacks for unsupported platforms.
There is no hard limit defined by the specification, but Chrome imposes a soft limit. In practice:
getTags() to audit your registered syncs and clean up obsolete ones with unregister().Register a periodic background sync to fetch fresh data even when the tab is closed. Understand the API and limits.
Register a one‑off background sync and see it fire when connectivity returns. Debug service worker sync logic.
Generate a pop signal to determine if speakers are wired in phase. Quick stereo test.
Display an astigmatism dial and instructions for self-assessment. Educational, not a medical diagnosis.
Hear a word spoken by browser TTS and type the spelling. Choose difficulty or paste your own list. Great for kids. Local only.
Configure how your PWA launches: focus existing or create new. Test with the launch_handler manifest field.
Check if the browser has captured the beforeinstallprompt event. Understand why your PWA is (or isn't) installable.
Override your browser's geolocation to any coordinates and test how your app responds. For development and privacy testing.
Hear text spoken word by word with boundary events. See the exact index and character. Advanced TTS dev tool.
Load a video and visually check if audio aligns with lips. Use frame‑by‑frame stepping. Debug playback issues.
Toggle a screen wake lock to prevent the device from dimming or sleeping. See the lock state and learn the API.
Check if your page triggers the beforeinstallprompt event. Simulate the install flow. Debug PWA installability.
Paste your Accept‑Language header and see which languages your site should serve based on quality values. Internationalization helper.
Test how your page loads under slow, 3G, or offline conditions by intercepting fetch and applying delays. No DevTools needed.
Override your browser's geolocation to any coordinates and test how your app responds. For development and privacy testing.
Check current screen orientation and test the lock API. Useful for mobile web apps. Demo with code.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
Test the Web Share API by sharing text, links, and files directly from the browser. Check compatibility and see example code.
Check if your browser and display support the wider DCI‑P3 color space. See the difference with a simple test pattern.
Enter any phrase and instantly see if it's a palindrome, ignoring spaces and punctuation. Fun for word nerds.
Generate random, formatted ID numbers that match pattern rules for various countries. For testing input validation. No real data.
Generate a subtle noise/grain texture as a CSS background pattern. Adjust opacity and size. For that film look.
Pick a method, URL, headers, and body, then send an HTTP request directly from your browser. Debug APIs easily.
Quickly test if your webcam, microphone, and speakers work correctly. See live video and audio meter. No data sent.
Generate random but realistic‑looking data arrays (users, products, orders) with typos and missing fields. For test robustness.
Simple interactive eye dominance test: hold up a virtual dot and see which eye stays aligned. Educational.
Build an iframe with different sandbox flags and see live which features are blocked. For secure embedding.
Simulate random mouse moves, clicks, or keystrokes to test idle‑timeout logic. Stops when you move the mouse. Dev test.
Paste a test card number to verify Luhn algorithm, identify issuer (Visa, MC), and check length. No real data.
Play left‑only, right‑only, and frequency sweeps to test your speakers or headphones. Quick audio check.