Reputation: 6421
Currently I have an ajax app that checks the server for updates every 10 seconds or so using setInterval(...). This seems like a resource intensive way of doing this. Is there are a more efficient way of getting updates from the server in real time?
Specifically I'm doing the above for a logging system. I have my 'logs' page open on my second monitor for a CMS I'm developing. Every 10 seconds the page checks the server for any new log entries. This allows me to see whats going on in semi-real time as I'm developing.
Upvotes: 1
Views: 241
Reputation: 2530
There is the websockets API, but it is not supported on all browsers. The latest draft is supported by Chrome 14, Firefox 7 and Internet Explorer 10. If this is for development only, and you use on of those browsers, that shouldn't be a problem.
This API will allow the server to contact the client as well as the other way around, so no polling needed anymore. See also the Wikipedia page for an introduction.
Upvotes: 1