Javascript Background Sync Stops Working If Page Is Loaded/refreshed While Offline
I'm currently learning how to use Background Sync as to allow users to PUT/POST changes while using a web app offline. I followed the instructions given by Jake Archibald in Intr
Solution 1:
Ok, I feel stupid. The browser is indeed the one that decides when to do the background sync.
The behavior I expected is wrong:
- Access app while offline.
- POST/PUT changes with Background Sync
- Go back online, refresh page see changes right away
Behavior the browser actually implemented:
Accessing app while online:
- Access app online.
- app goes offline (manually or not)
- POST/PUT changes with Background Sync
- app goes online, and refresh
- Changes are instant, since Sync happens as soon as app goes online. Browser is able to detect the change from online, to offline back to online?
Accessing app while offline
- Access app while offline.
- POST/PUT changes with Background Sync.
- app goes online, and refresh
- Changes aren't instant. Somehow the browser decides not to make the sync yet.
- Close browser completely, and come back to page
- The Browser syncs.
So is hard to know when the Browser will perform the sync, and only when accessing app while online, does the browser syncs if it detects a change from offline then online in same session (no refresh?)
Post a Comment for "Javascript Background Sync Stops Working If Page Is Loaded/refreshed While Offline"