I am designing a web based chat feature for an application that will work sort of like facebook chat or google talk inside of gmail. I’m wondering if anyone has any advice on how often it should check for updates? Every 2 seconds? Every 5 seconds? 10 seconds?
Also, should I call setTimeout in the callback function of setTimeout, or in the callback of the ajax request for updates? Basically, should it be n seconds between calls, or n seconds between the completion of the last request and start of the next?
Thanks
You could use something like Comet (AKA reverse AJAX) to have a persistent connection instead of pinging the server multiple times.
otherwise, I would say 2-3 seconds should be a good range. anything lower would be putting undue stress on the server, and anything longer would make the app feel sluggish.