CDN Test : How to Properly Setup and Test a CDN

CDN Test How to Properly Setup and Test a CDNCDN test procedures are  important for new CDN customers looking to optimise the way they deliver their data to end users. When setting up a new CDN, it is important to properly test the CDN setup so that you can determine that files can be served to end users quickly and efficiently.

Typically speaking, there are four ways of testing CDN setups.

 

CDN Setup Method 1: The Basic Method

This simple method involves setting up a CNAME to point to a CDN provider. For example, making static.example.com CNAME to example.com.clients.somecdnprovider.net.

After doing this, the browser cache must be flushed and time given for the DNS changes to take effect. You can then perform a CDN test by checking the site to see if anything is broken.

 

Method 2: Hosts File Editing

  1. Find the IP of example.com.clients.somecdnprovider.net
  2. Map that IP to static.example.com in your hosts file
  3. Clear browser cache and OS DNS cache
  4. You can then browse your site while keeping the developer tools of your browser open to ensure everything is working

 

Method 3: Manipulate GET HTTP Request

When you issue a GET request for website file (for example http://static.example.com/style.css), a specific process happens:

  1. The client gets the IP for static.example.com from the OS
  2. The client establishes a HTTP Connection with the returned IP
  3. The client asks the server for /style.css , and amongst the other request headers, it includes “Host: static.example.com”
  4. The server uses the information given by the Host header to know which virtual zone it may be mapped to. This is the most important request header.

This means that the server connection and Host header is completely under the control of the client. To test how this would work under a CDN, you must manipulate this information.

 

This can be done a few different ways:

To fetch the example file from the CDN you would issue the following command:

GET -H ‘Host: static.example.com’ http://example.com.clients.somecdnprovider.net/style.css

 

Or for curl:

curl -H ‘Host: static.example.com’ http://example.com.clients.somecdnprovider.net/style.css

 

ApacheBench:

ab -H ‘Host: static.example.com’ http://example.com.clients.somecdnprovider.net/style.css

 

The results of doing this is that the original process changes to:

  1. The client gets the IP for example.com.clients.somecdnprovider.net from the OS
  2. The client establishes a HTTP Connection with the returned IP
  3. The client asks the server for /style.css , and amongst the other request headers, it includes Host: static.example.com
  4. The server uses the information given by the Host header to know which virtual zone it may be mapped to. This is the most important request header.

 

Method 4: webpagetest.org

This is the simplest method for completing a CDN test and involves fooling the test browser into thinking that the CNAME switch has already been done using setDNSName