3 Tips to Reduce CDN Cost and Improve Performance


how to reduce cdn cost

CDN or content delivery network is the quickest way to transfer content from your application or website to users depending on their geographical location. CloudFlare, Amazon CloudFront, Fastly, Akamai, and KeyCDN are some of the popular CDNs out there. By using a CDN, you can move towards enhancing scalability and performance of your application or website. However, this is possible only if the CDN network is optimized to suit your specific requirements. This kind of customization will not just improve service performance it will help reduce CDN cost. Here are three ways in which you can do this:

 

Make Use of GZip

This open source file format is used to facilitate compression as well as decompression of files such as those using JavaScript or CSS. Pioneered by Linux systems it contains numerous software tools, use cases, and implementations. Primarily put use when data is in transit or static, it can help you compress files by 60 percent to 85 percent of actual size.

This, in turn, results in a 50 percent enhancement in performance while helping reduce CDN cost. Current browsers support GZip and receive the compressed files before efficiently retrieving them and incorporating them into the process of page load.

 

Determine a Default TTL (Time to Live)

TTL refers to the time for which a resource remains in the CDN cache and the browser cache before it is again retrieved from the origin. TTL can be fixed with the Cache-Control header using directives like “s-maxage” or “max-age”. For instance, if you want to delay an object that has been fetched from being fetched again or revalidated for 5 minutes or 300 seconds, the entry will read: ‘Cache-Control: max-age=300’.

Thus, the object will not be requested once again from the CDN for 5 minutes. You can increase the efficiency of service by restricting the number of times resources are validated or fetched from the origin. At the same time, it is necessary to make sure that fresh content is available to users.

Both these can be ensured by setting the TTL at the greatest possible value for the kind of content you are delivering. Thus, rapidly changing sites which witness frequent updates such as news sites or e-commerce sites will likely need short TTL of about 1 minute. In static sites, the TTL can be set at one week or more as required. You can also choose to set individual TTL values for CDN cache as well as browser cache.

 

Try to Disregard Query Strings

The piece of data attached to a URL that alters the request is known as a query string and is frequently used to transmit dynamic information like user IDs. If a query string is affixed to static content, the CDN, by default, will look at every query string as a unique object.

The CDN will send a fresh request to the origin and stash a new object on the CDN cache. Often, changes in the query string do not alter the static content or the images rendering waste any new request to the origin for these.

In such instances, where possible, you can stop the CDN making requests by going to “More Options” and choosing “Off” for the “Honor Query String” option and effectively reduce CDN cost.

 

After trying out these simple hacks, you might then consider moving on to more advanced techniques of further enhancing CDN performance and reining in costs.

mm

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!