views:

152

answers:

2

Guys, if you have any idea about the logic behind the slow connection in gmail

+5  A: 

I don't know if this is how Google does it (though it seems sensible), but what I'd do is perhaps time the initialisation process - e.g. "have certain key elements been initialised in the document within (say) 30 seconds" - if not, then propose to the user that their connection's slow. The language Google uses, as you know is, "this seems to be taking longer than normal", which suggests to me that they don't have an overly complicated solution to this.

Rob
@Rob 30seconds waiting for initialising. what if the server is out of service!!
Suresh S
That can be detected, as initializing can be quite a load of data, but detecting whether it is still online only takes a few bytes.
Dykam
I once looked at Gmail's sources (not everything, only the obvious parts) and this is exactly what Gmail does (and the timeout is indeed 30 seconds).
Marcel Korpel
+3  A: 

Here is (in vastly simplified form) how I'd imagine they do it.

// Pop an alert after 30 seconds
var timeout = setTimeout(function () {
                             alert('Your connection/computer is slow!');
                         }, 30000);

// Loading logic
loadStuff();

// When done loading (if it took less than 30 seconds), 
// calling this will prevent the alert from popping up.
clearTimeout(timeout);
Casey Hope