It’s that time of year again — the kids are off at camp, your air conditioner is on full blast and you just realized the holiday season is only a few months away.
Time to start reviewing your web site’s performance, planning for holiday spikes and making changes before the dreaded “holiday code freeze” is upon you.
Don’t sweat it, Rackspace is here to help. We’ve got simple and effective tools to help improve your website’s performance, like using Rackspace Content Delivery Network (CDN) to get your site’s load times down. Let’s get your users browsing deeper, getting more engaged, and shopping longer.
Most people understand that a CDN will improve the performance of their website, but many hesitate to implement it for fear of breaking something. And it’s true, implementing a CDN for the first time can be a bit daunting. But fear not! Below are some quick tips to ensure you don’t break anything:
Tip 1: Set Up a Test Domain
Setting up a test domain is useful. If you have automated (or even manual) test suites, run them against your cdntest subdomain. Every time you want to make an update to your CDN configuration, test it out on your test domain first, keeping production traffic as-is.
Luckily, setting up a test domain for use with CDN is simple. If the site you want to accelerate is located at say, www.bloggingexample.com, you can create a test domain by adding a new subdomain to your root domain. You’d set up “cdntest.bloggingexample.com” to use as the test domain. Start by creating a CDN service with your domain listed as “cdntest.bloggingexample.com.” To ensure you’re testing a real production scenario, you’ll want to set your origin as the IP address of the webserver that’s running your production traffic.
This means when you visit www.bloggingexample.com directly, your traffic won’t be served over CDN. Once your test domain is set up, when you visit cdntest.bloggingexample.com, your requests will go over the CDN. This gives you the ability to compare performance and function on your CDN and non-CDN sites.
Once the test CDN service is set up, go to your DNS provider and create a new CNAME record that points your new test domain (“cdntest.bloggingexample.com” in our example above) to the CDN URL Rackspace gave you when creating a CDN service.
Tip 2: Compare performance and functionality
Start by testing the performance of your site without CDN. This will give you a performance benchmark. If you decide to use one of the popular free testing sites like webpagetest.org, it’s important to understand that running tests that aren’t representative of your actual traffic may be misleading.
If you are running a single test on webpagetest.org, you may see different results from run to run. To get a better representation, look for a site that will run hundreds of tests from different locations. Still, using free tools can still be quite useful. Webpagetest.org, for example, is perfect for getting an idea of which assets are slowing down your site. For example, let’s run a test on my favorite site, www.poppycdn.com.
Pro tip: If you are using webpagetest.org, click the “waterfall view” to see per asset load times.
I can see that images I’m pulling from Github are costing me in load time, so I may want to consider storing those images directly on my webserver and using CDN to accelerate them instead. Outside of those images, content in my “static” directly is the slowest. I’ll talk about optimizing performance with caching rules in the next section.
Tip 3: Tweak your Caching rules
Rackspace CDN allows you to setup “caching rules,” which tell the edge how long to serve a file from the cache before it checks your web server for a fresh copy. If you don’t set any caching rules, Rackspace CDN will cache all your content by default.
However, if you have a highly dynamic site, you probably don’t want everything cached. In this scenario, we recommend that you set rules that tell the edge to pass everything through to your origin, except files and folders that you specifically want cached. This means your caching rules might look something like this:
This set of rules tells the CDN:
- Don’t cache anything on my site
- Unless the request path contains “/images/”, then cache it for one day
- Or unless the request path contains “/content/scripts/*, then cache that content for one day as well
Once you identify content that could benefit from CDN, create a caching rule for it. Rackspace CDN accepts wildcards in rules, so if you want every file with a request path of “/images” to be cached, then set the rule with a path of “/images/*” like this:
Again, you only need to worry about this if your dynamic content prevents you from caching your entire site.
Keep adding, subtracting and working with your caching rules until you get the performance you want. Webpagetest.org is free, which makes it easy to quickly see the impact of changes you are making.
Once your site is running smoothly and your caching rules are in place (if you need them), it’s time to get your production site on CDN. To do this, you’ll create another CDN service, this time using your www site as the domain.
Again, Rackspace CDN will return a CDN URL. Simply CNAME your www domain to the CDN URL, and you are ready to go!
If you have any questions about this process or how Rackspace CDN works, feel free to ask them here, or contact me directly at email@example.com.