3 Simple Steps to Leverage CDN Caching

By Martin Williams
Updated on June 27, 2016
3 Simple Steps to Leverage CDN Caching

It is important to properly leverage the CDN caching mechanisms for best performance. This article provides you a best-practice guideline on how to set the Cache-Control header and how to handle cached assets.

1. Use the Cache-Control header

In general we recommend to leave the default cache related settings of your Zone as they are, such as the Expire, Max Expire, and Ignore Cache Control settings.

Setting Ignore Cache Control to disabled will enable the processing of Cache-Control response header fields from the origin server, such as Cache-Control and Expires. Avoid to use the private or no-cache directive because they force a CDN to not cache your content, thereby not accelerate your assets. The Cache-Control and Expires headers should have the following format:

Cache-Control: max-age=86400
Expires: Tue, 12 May 2015 09:47:12 GMT

2. Set the expiry of at least a week

Setting the expiry to a week (604800 seconds) is a recommended value for assets that do not change often.

Cache-Control: max-age=604800

The Expire setting defined in your Zone settings has only an impact on the web browser cache and not on the KeyCDN cache. The Max Expire setting specifies the maximum time that cacheable HTTP documents will be retained without checking the origin server. You can set the value of both directives to 10080 minutes.

3. Purge updated files instantly

You can purge files in the KeyCDN dashboard or through the API if you want to delete the files from the CDN cache before they expire. The purging from the CDN cache happens instantly. You can decide to purge specific files or the complete cache of your Zone.

We are providing various plugins to simplify the purging through our API:

KeyCDN API adapters

Simply integrate the KeyCDN API with any of the following adapters into your application.

Task automation plugins

Frontend automation systems are commonly used. Grunt is rather a task based system where Gulp is based on streams. The following plugins help you to easily integrate them into your task flow.

  • Share

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started

Comments

Comment policy: Comments are welcomed and encouraged. However, all comments are manually moderated and those deemed to be spam or solely promotional in nature will be deleted.
  • **bold**
  • `code`
  • ```block```
KeyCDN uses cookies to make its website easier to use. Learn more