Sohail Ahmed
Sohail Ahmed

Reputation: 123

Parallelize downloads across hostnames HTML Site

I have been using maxcdn, just read an article on how to improve Site performance. "Parallelize downloads across various hostnames" got my attention.

However, I have been using HTML site and not wordpress. Therefore Implementing it isn't not gonna be easy for me.

I have been using :

<base href="https://cdn.domain.com/">

How should i develop a script that will choose cdn1 cdn2 etc? Any help appreciated !

Upvotes: 1

Views: 329

Answers (1)

Noam Hacker
Noam Hacker

Reputation: 4835

A simple solution would be to choose a random CDN for each request. The probability that any given CDN will be chosen will be equal for all CDNs. Say you have 3 CDNs:

<script>
    var number = Math.floor(Math.random() * 4);
    var url = "https://cdn" + number + ".domain.com/";
    document.write("<base href='" + url + "'>");
</script>

Upvotes: 1

Related Questions