Wednesday, October 15, 2014

Testing CDN and geolocation with webpagetest.org

Assume you want to migrate some.example.com to a new CDN provider. Eventually you'll have to point example.mycompany.com as a CNAME to a domain name handled by the CDN provider, let's call it example.cdnprovider.com. To test this setup before you put it in production, the usual way is to get an IP address corresponding to example.cndprovider.com, then associate example.mycompany.com with that IP address in your local /etc/hosts file.

This works well for testing most of the functionality of your web site, but it doesn't work when you want to test geolocation-specific features such as displaying the currency based on the users's country of origin. For this, you can use a nifty feature from the amazing free service WebPageTest.

On the main page of WebPageTest, you can specify the test location from the dropdown. It contains a generous list of locations across the globe. To fake your DNS setting and point example.mycompany.com, you can specify something like this in the Script tab:

setDNSName example.mycompany.com example.cdnprovider.com
navigate http://example.mycompany.com

This will effectively associate the page you want to test with the CDN provider-specified URL, so you will hit the CDN first from the location you chose.

2 comments:

Scumola said...

Yea, they have an API. I hit our site with webpagetest.org using a few different browsers every hour and collect all of their stats. It's good to look at every month or so to see if the "time-to-load" or another stat is changing unexpectedly.

Grig Gheorghiu said...

Hey Steve! Thanks for the info, it's definitely something I'll look into.