TechnoMagicians Blog

Any sufficiently advanced technology is indistinguishable from magic – Arthur C. Clarke.

TechnoMagicians Blog header image 2

Multipart XMLHttpRequests (MXHR)

May 21st, 2009 · No Comments

The folks at Digg have come up with what they are calling Multipart XHLHttpRequests (MXHR). Basically it is a method for bundling multiple HTTP requests into a single HTTP request and unbundling on the client side through a Javascript handler.

As described by the Digg’s blog post:

We call this technique MXHR (short for Multipart XMLHttpRequests), and we wrote an addition to our Digg User Interface library called DUI.Stream to implement it. Specifically, DUI.Stream opens and reads multipart HTTP responses piece-by-piece through an XHR, passing each chunk to a JavaScript handler as it loads.

Why do this? Well, DUI.Stream will allow developers to drastically improve the speed of uncached page loads by bundling most of their resources into a single HTTP request, with a single time-to-first-byte and no request throttling by the user agent. Additionally, the size of the response has no effect on the rendering time of each chunk, as the client handles each piece of the response on the fly and can inject it into the DOM for rendering immediately, in the exact order you specify. On a high traffic, high-activity site like Digg, we have to display incredible amounts of data on each permalink — typically hundreds of user images within the first 50 comment threads on a page alone, not to mention the UI chrome and actual comment data. (You can see this for yourself: notice the number of HTTP requests that queue up when you expand a page of comments). So our primary use case for DUI.Stream is turning that first long, arduous page load on an empty cache into something nearly indistinguishable from a page of data with fully cached resources.

Try out the 2nd demo with the images to really see how this works.

Category: Software Development

Tags: , , , , , , , ,

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment