0

I have grid that needs to be auto updated every minute. I want to update grid asynchronously so that web page does not send any request to server. Only the server will know when to sent new lets say JSon data to client. Is this possible? Can I send data to client with out pinging the server?

Thanks.

eomeroff
  • 9,599
  • 30
  • 97
  • 138

2 Answers2

0

No. You'd have to use some kind of open socket, which is a very low-level form of pinging anyway. The standard is to simply have a frequent but very short JSON request to check for new data.

Edit- There is WebSocket, but it appears that the implementation on the server side is more advanced & you'd be crippling your audience reach. Just do frequent, short JSON requests.

Community
  • 1
  • 1
Tim
  • 14,447
  • 6
  • 40
  • 63
0

No, you have to send a HTTP request to get a response. The delay between the request and the response can be as long as you want, however (so please don't aggressively poll for updates):

http://en.wikipedia.org/wiki/Push_technology#Long_polling

You simply make a request, wait for it to complete (when something happens), start another request immediately and then process the response.

This way, the server always has a request ready which it can respond to in order to "push" to the browser (or one will shortly be made).

James M
  • 18,506
  • 3
  • 48
  • 56
  • > The biggest hurdle is the HTTP 1.1 specification, which states that a browser should not have more than two simultaneous connections with a web server. Therefore, holding one connection open for real-time events has a negative impact on browser usability: the browser may be blocked from sending a new request while waiting for the results of a previous request, e.g., a series of images. – Tim Feb 17 '12 at 16:09
  • @Tim You start the first poll _after_ the page has loaded. This approach is used successfully by Facebook etc. – James M Feb 17 '12 at 16:11
  • Plus, I just checked `network.http.max-connections-per-server` in Firefox. It defaults to _15_. – James M Feb 17 '12 at 16:13
  • its 2 for IE and only goes to 4 for IE9 i think, this can be got round be using subdomains though so that the long poll requests are sent to a different sub domain and this dont tie up the limited connection to the main site. – Dampsquid Feb 17 '12 at 16:16