I guess I'm missing something here, but shouldn't AJAX be slowed down by latency a lot more than WebSockets? AJAX (usually) opens a new TCP connection for every message, while WebSockets establish a connection once and use it for all messages. So shouldn't AJAX need one roundtrip more (SYN/SYN+ACK) than WebSockets and thus take twice the latency (assuming that the payload is small enough to fit in one IP packet)?
Need to check up on the behaviour but AJAX POSTs used to take two packets - headers get sent in first and then once the server ACKs the client sends the body of the request.
Yahoo discovered and documented it several years back
Comment
Is this perhaps skewed because the server sends a Keep-Alive header?
Parent comment
I guess I'm missing something here, but shouldn't AJAX be slowed down by latency a lot more than WebSockets? AJAX (usually) opens a new TCP connection for every message, while WebSockets establish a connection once and use it for all messages. So shouldn't AJAX need one roundtrip more (SYN/SYN+ACK) than WebSockets and thus take twice the latency (assuming that the payload is small enough to fit in one IP packet)?
Replies
Would be interesting to compare with and without Keep-Alive and also the difference between GET and POST
There's not really a difference between GET and POST requests, except how the server handles them.
Need to check up on the behaviour but AJAX POSTs used to take two packets - headers get sent in first and then once the server ACKs the client sends the body of the request.
Yahoo discovered and documented it several years back