How to Fix “Parallelize Downloads Across Hostnames”
access_time
hourglass_empty
person_outline

How to Fix “Parallelize Downloads Across Hostnames”

Most website speed test tools show the “parallelize downloads across hostnames” warning if it finds potential connection issues on your website. While in most cases it is easily fixed, in certain situations you can simply ignore it.

In this article, we will learn what causes the “parallelize downloads across hostnames” warning and how to solve this issue.

What Causes the Error to Appear?

The “parallelize downloads across hostnames” error is usually seen on websites that have a lot of requests. Here’s how that happens:

The HTTP 1.x protocol determines that single-user clients can have a maximum of two connections with any server. That means it might create a backlog if there are too many resources in queue to load.

On the other hand, most browsers have some limitations too — maximum of six connections per domain. If you have too many tabs opened, you will easily reach this limit.

In most cases, people will attempt to make reconnections, or try to provide multiple subdomains to avoid the restriction (we’ll talk about it later).

Yet, this situation happens only on an HTTP 1.x connection.

If you are using HTTP/2 with a secure connection, this will no longer be a problem. HTTP/2 is a revised version and allows parallel downloads. Considered to be outdated, most hosting providers, including Hostinger, use HTTP/2 instead of HTTP 1.x.

That being said, it is safe to ignore the “parallelize downloads across hostnames” warning while you are on HTTP/2 connection.

Some tools like GTMetrix or Pingdom might still give this error — using different names — regardless if it’s an actual problem to you.

Fixing “Parallelize Downloads Across Hostnames” Error

As previously mentioned, to avoid restrictions, people try to manage the assets using subdomains to deceive the browser and allow more parallel connections. This practice is called domain sharding.

Domain sharding is a method to increase the number of simultaneous resources downloads using multiple subdomains. So, you can use domain sharding to fix the “parallelize downloads across hostnames” error.

Keep in mind that domain sharding will leave negative side effects too, like:

  • An increase of DNS lookup times
  • Loss of caching capabilities
  • Potential issues on mobile device browsers

Basically, there are two steps for domain sharding – setting up subdomains and editing the function.php file.

Setting Up Subdomains

The first step of domain sharding is to create multiple subdomains or CNAME records. However, this can split the request for your static content.

To do that, you can go to your hPanel, then choose the Subdomains under the Domains category.

Domains category in hPanel

Enter the subdomain name in the blank field and then click Create. You can repeat this step to create multiple entries. Most of the time, adding three subdomains would be enough.

Creating subdomains in hPanel

Once the subdomains are set, you are ready to edit the functions.php file.

Setting up subdomains

Editing Your WordPress functions.php File

The second step of domain sharding is editing the WordPress function.php file to parallelize hostnames.

You can go to your WordPress Dashboard -> Appearance -> Theme Editor and then choose Theme Functions (functions.php).

Next, add the following code to the functions.php file:

function parallelize_hostnames($url, $id) {

$hostname = par_get_hostname($url); //call supplemental function

$url =  str_replace(parse_url(get_bloginfo('url'), PHP_URL_HOST), $hostname, $url);

return $url;

}

function par_get_hostname($name) {

$subdomains = array('media1.mydomain.com','media2.mydomain.com'); //add your subdomains here, as many as you want.

$host = abs(crc32(basename($name)) % count($subdomains));

$hostname = $subdomains[$host];

return $hostname;

}

add_filter('wp_get_attachment_url', 'parallelize_hostnames', 10, 2);

Please note that you need to change $subdomains values with the subdomains you created. Also, make sure that all of the subdomains have the same path to avoid any errors.

Once you finished, click Update File. And that’s it!

You can also follow the same steps with CDN providers – like KeyCDN – to fix the “parallelize downloads across hostnames” error. However, as most CDN providers use HTTP/2, domain sharding is not recommended.

Summary

If you ever run into “parallelize downloads across hostnames” warning when testing out your website, don’t panic. It happens due to the limitation of the browser and HTTP 1.x connection.

In summary, you can fix the error using the domain sharding method in two steps:

  1. Setting up subdomains
  2. Editing functions.php file

However, if your hosting provider already uses HTTP/2, you can safely ignore this error.

The Author

Author

Suryadi K. / @suryadi

Suryadi, an avid content writer with years of IT experience, keeps on pursuing opportunities to engage with more people through articles about WordPress and other issues. During his free time, he enjoys playing Clash Royale.

Related tutorials

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Become a part of Hostinger now!

More in Website
How to Monitor Your Website Performance for Uptime/Downtime

Close