Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline page should periodically test for restored connection #42

Open
TalAter opened this issue Sep 1, 2015 · 4 comments
Open

Offline page should periodically test for restored connection #42

TalAter opened this issue Sep 1, 2015 · 4 comments

Comments

@TalAter
Copy link
Owner

TalAter commented Sep 1, 2015

Offline page can register a listener for restored connection.
Only check internet connection when a listener is registered.

See also #14

@hye
Copy link

hye commented Sep 2, 2015

👍
and maybe navigator.onLine should check first

@TalAter
Copy link
Owner Author

TalAter commented Sep 2, 2015

Interesting, I didn't know this one. Thank you 👍

The property sends updates whenever the browser's ability to connect to the network changes. The update occurs when the user follows links or when a script requests a remote page.

In Chrome and Safari, if the browser is not able to connect to a local area network (LAN) or a router, it is offline; all other conditions return true. So while you can assume that the browser is offline when it returns a false value, you cannot assume that a true value necessarily means that the browser can access the internet.

Might not be good enough… If a user just has the page sitting in the browser, waiting for the connection to go back online, navigator.onLine won't change… not until the browser tries to access the network. Perhaps we need to initiate a network request periodically (need to make sure this is only done when a page in the scope is shown).

@yankeeinlondon
Copy link

I think the onLine indicator would be nice but I think it's implementation is inconsistent across the different browsers. I think periodic network polling is unfortunately the only reliable way of testing this (see offline.js for a popular solution). This "cost" however is pretty minimal and since it may in fact be beneficial to retry some of the cached content from time to time you could kill two birds with one stone (aka, check the network by checking for updates to content of existing cache content).

@TalAter
Copy link
Owner Author

TalAter commented Jan 1, 2016

@ksnyde I agree, and the checked cached content with the same stone is a great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants