3 Tips for Cloudfront Configuration – LoadStorm

In High Performance Web Sites: Essential Knowledge for Frontend Engineers by Steve Souders[book] (not in preview), it was stated that “At Yahoo!, properties that moved static content off their application web servers to a CDN improved end-user response times by 20% or more.” In addition, we here at the Web Performance Lab have even seen scalability increases as high as 1400%! If you want a responsive site for everyone, even someone trying to access it from a remote island in the Pacific, you might consider implementing a Content Delivery Network (CDN) distribution. In the past, we have posted articles about the benefits of CDNs. You can check one of them out here. Now let’s say you decided to use Cloudfront. You’ve got your own Cloudfront distribution up and running for your website, but what now? What you will find below are three tips for modifying the Cloudfront configuration of your existing CDN distribution:

Add Behaviors

Modern websites aren’t uniform; every section of a website has different needs. Behaviors are a way to make the CDN distribution act specifically for different parts of your website. An example is adding a new behavior for the path “/login*” to use HTTPS Only.

The distribution will know that anywhere in your site that has that login path will serve only HTTPS (i.e. https://example.com/login/customer). The Default(*) behavior is then used last and applies to all other folders and files in your site. As a second example, you might want the “/products*” portion of your site to be quick and refresh consistently. This leads to the next tip we can employ in our distribution.

Use Custom TTL

Not only are websites not uniform, they are not created equal. In this case it is beneficial to use a Custom Time-to-Live (TTL) cache header for your distribution. TTL determines how long your distribution edge servers will wait before refreshing content from the origin servers. The TTL is measured in seconds not minutes. Some of the TTL values we used for testing Delivergood’s distribution were 600 (10 minutes) and 3600 (1 hour, below).

For your distribution though, it depends on how frequently you want your site to update. Does your site frequently push new content? Lower the Custom TTL. Is the site mostly the same content and used as a repository or mirror? Raise the Custom TTL. This setting coupled with behaviors lets you balance the distribution to match your site’s needs.

Change The Price Class

You might have already noticed this setting and it speaks for itself. Say you want your site to perform faster, but you don’t need it to be optimized globally. Perhaps your website is for a local business and you don’t need it to perform optimally for geographically distant visitors. If you want to save money, change your Price Class in the set up of your distribution to use the regions that are closest to the location of your web server rather than Best Performance (All Locations). Below is a snapshot of Amazon’s price class pricing:

Clearly some regions are more costly than others. Serving content from Japan is 67% more costly than the US, while South America is 108% more! An example might be if you have origin servers in North America. Your best choice would be the “Use Only US and Europe” price class to still serve content fast to those regions (but not as fast globally) for a cheaper price.

Employing these three tips are only a few ways to customize your CDN distribution. There are ways you can further tweak the CDN. You could add additional origin servers with different rules and locations, or set up an RTMP distribution for streaming media. If you work with CDNs yourself and know any additional tips, feel free to leave a comment!

Similar Posts