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.
Override your browser's geolocation to any coordinates and test how your app responds. For development and privacy testing.
Connect an audio source to an Analyzer Node and display frequency and time‑domain data. Learn Web Audio visualization.
Pick a method, URL, headers, and body, then send an HTTP request directly from your browser. Debug APIs easily.
Select HTTP method, set headers, and body. Send requests and see the full response. Lightweight Postman alternative.
Measure your browser's GPU compute power using a simple WebGPU matrix multiplication. See raw FLOPS and compare with peers. Fully client‑side.
Use your microphone to detect the dominant frequency of ambient sounds. Visualize the spectrum. Local Web Audio.
Record how many eggs your hens lay each day. Visual chart shows weekly trends, helping you spot drops in production that may signal health issues.
Trigger different vibration patterns on mobile devices. Test if your phone supports haptic feedback. Simple demo.
Pomodoro timer with built‑in lo‑fi music playlist (synthetic). Focus and rest cycles. No copyright music; generated tones.
Simulate adaptive bitrate logic by switching between different quality video segments. See how ABR algorithms work.
Zoom through the electromagnetic spectrum from radio waves to gamma rays. See wavelength, frequency, and applications. Static educational page.
Process audio faster than real‑time with OfflineAudioContext. Apply filters and export the result. Dev tool.
Experiment with the experimental Prompt API and Summarization API right in your browser. See how the on‑device AI model responds. Requires Chrome with AI features enabled.
Read the ambient atmospheric pressure in hPa using the Pressure Sensor API (if available). Real‑time graph.
Use the Magnetometer API to build a digital compass. See magnetic field strength and heading in real time.
Mix multiple ambient sounds (rain, fireplace, coffee shop) to create your perfect productive background.
Play a selection of local lo‑fi tracks (embedded). Simple UI with play/pause. No copyright issues. Stay focused.
Mix white noise, pink noise, rain, thunder, wind, and cafe sounds. Individual volume, save presets. Relax or focus. All client‑side.
Measure the integrated loudness of an audio file in LUFS and RMS. Check if your music meets streaming platform standards. Client‑side.
Play a simple monophonic synthesizer with your keyboard. Choose waveform, attack, decay, and filter. For music fun.
Change the viewport meta tag and see how a page would render at different device widths. Understand responsive basics.
Record daily systolic/diastolic readings and pulse. See a trend chart. All data saved locally in your browser.
Load an audio file and see its spectrogram with frequency over time. Adjust resolution and color map. Discover hidden sounds.
Find your public IP address and view approximate geolocation, ISP, and browser header details. No personal data stored. Static and instant.
Apply lowpass, highpass, and reverb to an audio source. See frequency response. Create your own guitar pedal. All local.
Drag a battery, resistor, LED onto a grid and simulate current flow. Show Ohm's law in action.
Mix realistic rain sounds with optional thunder and wind. Adjust individual volumes to create the perfect sleep or study atmosphere.
Test the experimental Translation API to translate text between languages directly in the browser, without cloud calls. Check support and copy the JavaScript starter.