How to update data in real time?

8

Sites such as Facebook, Twitter even this we are now are updating their data in real time, in the case of Facebook: when a user likes some post automatically the data on your screen are updated and so on, but I went on the network of Chrome and realized that there are no "requests", how are these updates made?

    
asked by anonymous 28.07.2014 / 14:55

1 answer

11

The name of this type of technology is Push (Push ), where the server initiates a transaction with the client (in this case, the browser).

It's the inverse of what we usually use in web applications, where the action is on the client side (Pull ).

In this mechanism, the client state changes upon request from the server. There are several ways to implement this behavior in modern browsers:

  • Traditional Polling : Your application asks from time to time, via XMLHttpRequest or equivalent, if the server has any status updates.
  • Long-polling : Your application maintains an open parallel request that is only closed when the server sends some content.
  • Forever Frame : Same as Long-polling, but without the overhead of creating / destroying client control objects, and usually with a permanent connection.
  • WebSockets : A relatively new protocol (2011) that operates in parallel to HTTP and optimizes bidirectional communication between client and server.

For more information, check Wikipedia entry .

    
28.07.2014 / 17:51