HTML5 Client: What is the difference between Websockets and XHR?

Websockets is the persistent connection that can be used to receive/send data without sequential order and without http header.

Xhr-polling creates new request with http header and waits for answer with http header, also sequential order.

Doing so, XHR data flow always looks like this:

HTTP_HEADER_REQUEST -> HTTP_HEADER_ANSWER
HTTP_HEADER_REQUEST -> HTTP_HEADER_ANSWER
and so on

also before the data can be downloaded, it must be requested with HTTP_HEADER, therefore its name: xhr-polling.

Websockets data flow may look like this:

FRAME_DATA_SEND
FRAME_DATA_SEND
FRAME_DATA_RECEIVE
FRAME_DATA_SEND
FRAME_DATA_RECEIVE
FRAME_DATA_RECEIVE

Also it is random data sending/receiving without special sequential order and without any http header data.

That makes the usage with reverse proxies impossible due to the lack of Websockets support by most known reverse proxies; but half of the xhr transport may work with Apache reverse proxy.

Also see: HTML5 Client: Supported Browsers