This year, Digg came up with a method for scalability and speed for AJAX applications by optimizing XMLHttpRequests (XHR) into what is dubbed Multi-part XMLHTTPRequests (MXHR).
While some users reported little to no difference in client-side performance gains, MXHR extends beyond this for optimization.
The premise behind MXHR is that instead of sending an AJAX request individually for comments, usernames, images, and so on, it bundles all of these into one and sends it to the client.
Fewer HTTP requests will reduce the latency for the end user. Each time an AJAX request is initiated, the ping to the server and the ping from server to client needs to be accounted for. For multiple requests, this can substantially increase load times for the end user. By packaging everything into one request, we only have to worry about two hops: sending to the server, and receiving from the server.
However, there’s a little more to this. By using MXHR and packaging all the data into one, we can further compress the packaged data. This can trim tremendous bandwidth costs for high-demand web applications. Furthermore, encrypting packaged data is much more secure.
Each HTTP request to the server costs bandwidth (even if you didn’t receive any data from the server). This technique significantly reduces overhead.
So while MXHR may only provide marginal differences in smaller applications, and while some users may not notice a difference at all, the real use for MXHR are the savings it provides for the server(s).
Tags: AJAX, multi-part, mxhr, optimization, speed, xhr, xmlhttprequest