Parallel Downloads

The biggest impact on response time is the number of components in the page. Each component generates an HTTP request when the cache is empty, and sometimes even when the cache is primed. Knowing that the browser performs HTTP requests in parallel, you may ask why the number of HTTP requests affects response time. Can't the browser download them all at once?

The explanation goes back to the HTTP/1.1 specification, which suggests that browsers download two components in parallel per hostname (http://www.w3.org/protocols/rfc2616/rfc2616-sec8.html#sec8.1.4). Many web pages download all their components from a single hostname. Viewing these HTTP requests reveals a stair-step pattern, as shown in Figure 8-1.

Downloading two components in parallel

Figure 8-1. Downloading two components in parallel

If a web page evenly distributed its components across two hostnames, the overall response time would be about twice as fast. The HTTP requests would behave in the pattern shown in Figure 8-2, with four components downloaded in parallel (two per hostname). To give a visual cue as to how much faster this page loads, the horizontal width of the box is the same as in Figure 8-1.

Downloading four components in parallel

Figure 8-2. Downloading four components in parallel

Limiting parallel downloads to two per hostname is a guideline. By default, both Internet ...

Get High Performance Web Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.