How to Fix “Parallelize Downloads Across Hostnames” Warning

When testing a website for performance using popular online tools like GTMetrix, Pingdom, Google PageSpeed, sometime we might get “Parallelize Downloads Across Hostnames” warning.  This warning means that your website’s assets are delivered from the same host name, and it would slower the site’s speed.

There is a limitation on the number of concurrent connection that web browsers will make to a host. For HTTP/1 and HTTP/1.1 connections, a web browser is only able to download one file at a time.

When there are many assets (images, javascript, CSS, etc) to be downloaded, the web browser will make many connections to the server to finish downloading the assets.

The time spent waiting for a connection to finish is referred to as blocking. Reducing this blocking time can result in a faster loading page. For example, In HTTP/1.1, when you open a website, your web browser requests for an image file, and make another requests once it receive a response from the server. It’s a synchronous connection, once you send a request you’re stuck until you get a response.

How to Fix Parallelize Downloads Across Hostnames warning

Actually, this has been deprecated since 2015, when HTTP/2 was introduced. The issue in latency that is caused by assets download queue has been solved by multiplexing in HTTP/2. Multiplexing means the web browser can send multiple requests and receive multiple responses in a single connection, not in a multiple connections as in HTTP/1.1

To fix this warning, you have several options:

Upgrade to HTTP/2

This is the easiest way to solve the Fix Parallelize Downloads Across Hostnames warning when making some tests for your site’s speed. In order to use HTTP/2, you will also need to implement HTTPS. Don’t worry, HTTPS in HTTP/2 is much faster if compared with HTTPS in HTTP/1.1. If you are using

Use CDN

Almost all CDN providers are now using HTTP/2, so you don’t need to do anything if you are using CDN to serve your static files.

Use domain sharding

This is an old method, if you are still using HTTP/1.1, you can follow the steps below to fix the “Parallelize Downloads Across Hostnames” warning. The following steps are for WordPress based websites.

Add CNAME

Add 3 (three) CNAME records to your DNS entry, like:

static1.yourdomain.com
static2.yourdomain.com
static3.yourdomain.com

Create VHOST file

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot “/var/www/html/yourdomain.com/wp-content”
ServerName static1.yourdomain.com
ServerAlias static2.yourdomain.com static3.yourdomain.com
ErrorLog “/var/log/httpd/yourdomain.com-error_log”
CustomLog “/var/log/httpd/yourdomain.com-access_log” combined

<Directory “/var/www/html/yourdomain.com/wp-content”>
Options -Indexes
Require all granted
</Directory>
</VirtualHost>

Edit functions.php

Go to your website dashboard – Appearance – Editor – Select Theme Functions (functions.php). It’s always a good idea to take backup of your functions.php before doing modifications. You can then paste the following code anywhere in your functions.php, but please add it after <?php in the first line, to make it easier to remember the modification you made.

function parallelize_hostnames($url, $id) {
$hostname = par_get_hostname($url);
$url = str_replace(parse_url(get_bloginfo('url'), PHP_URL_HOST), $hostname, $url);
return $url;
}
function par_get_hostname($name) {
$subdomains = array('static1.yourdomain.com','static2.yourdomain.com');
$host = abs(crc32(basename($name)) % count($subdomains));
$hostname = $subdomains[$host];
return $hostname;
}
add_filter('wp_get_attachment_url', 'parallelize_hostnames', 10, 2);


Of course you don’t have to Fix Parallelize Downloads Across Hostnames warning yourself, if you use one of our Cloud VPS hosting, in which case you can simply ask our expert Linux admins to Fix Parallelize Downloads Across Hostnames warning, on your websites. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Fix Parallelize Downloads Across Hostnames warning, please share it with your friends on the social networks using the buttons below or simply leave a comment. Thanks.

Leave a Comment