If you your site runs on CDN service, you may be interested in ways to optimize its work and make it even faster than before. Here are some techniques worth of anybody’s consideration, because they are commonly beneficial for caching and performance being cost-efficient.
Setting a Default TTL
Setting a default time to live (TTL) for cached data is defined by the type of your website. If you have a news site that is updated several times a day, TTL of two minutes may be required. On the contrary, an e-commerce website where information stays almost the same every day may have a default TTL of 1 week. Ideally, browser cache time should be a bit shorter than CDN cache time so that a user would load data locally from browser instead of transferring CDN cache of original server. To find out what optimal TTL should be like, analyze how often web-site is updated, and how often it is visited by an average customer.
Strip Cookies for More Cache Hits
When a static object sets cookies on the client’s side, CDN assumes that cookies are dynamic, which causes cache miss. Check whether your origin server sets cookies, and, if it is allowed, change it. If that is not possible, see if your CDN can ignore cookies from origin server’s response. That will boost CDN ability to cache objects.
Ignore Query Strings for More Cache Hits
Query strings can create the same problem of cacheability as described above. When they are included in URLs of static objects, they are considered to be unique objects and are requested from the origin server every time. It results into less cache hit value. If you disable such option, CDN will ignore query strings, which will improve cache hit.
Use the If-Modified-Since Header
When a TTL file expires on CDN, it pulls a new copy from the origin server, even if the file was not changed. That results into unnecessary bandwidth consumption. The If-Modified-Since header may be used in requests from CDN to the origin server. Studies show that If-Modified-Since cuts origin strain by 70%, and that helps to offload the origin server considerably.
Select an Appropriate Pricing Model
CDN market offers two different pricing models: per-gigabyte pricing and pipeline pricing. Simply stating, the first variant is good for sites with fluctuating traffic, while the second one will be suitable for web-sites with more or less stable traffic patterns. With per-gigabyte pricing client may have a certain amount of bandwidth a month that can be used when and how needed. With pipeline pricing (also called 95/5 pricing), certain amount of bandwidth per second is set. It is cheaper, and is better or sites that don’t experience considerable traffic spikes.