How to optimise your website’s caching efficiency

Caching is the key to optimum website performance. This article describes how you can make sure that your website uses the freistilbox content cache as efficiently as possible.

Content caching

Website content will only be cached if the HTTP headers it gets delivered with allow it.

In the following cases content can not be cached:

  • Your website sends HTTP headers that actively prohibit caching (for example, “Cache-control: no-cache”)
  • Your website sends HTTP headers that make the content individual in any way (for example, cookies)

If your website allows the content for a certain request to be cached, the caching server will deliver this content until it expires. The duration for which cached content gets stored and delivered depends again on certain HTTP headers.

The most important header is “Cache-control”. It can contain the value “max-age” which defines how many seconds certain content may be stored in the cache. For example, a value of “max-age=300” means that the cache content will expire after 5 minutes (300s).

In order to test how effectively your website’s content is getting cached, you check its HTTP headers.

How to check HTTP headers

There are many tools that help you check the HTTP headers of your content. Most current web browsers offer “developer tools” that will display the header information.

Alternatively, you can use the command line:

curl -I

How to avoid unnecessary individual content

This is the most important aspect in terms of caching because as soon as content looks “individual” to the caching server, it will not be cached.

The most common cause of “individualisation” is cookies. If content comes with a cookie, it’s obviously meant for this single visitor, so caching it for later requests makes almost no sense.

To prevent cookies from inadvertently killing your website’s cache efficiency, our cache servers will remove every cookie that is not a Drupal or WordPress session cookie. In consequence, plugins, modules or JavaScript add-ons that use cookies will not work on freistilbox. If you need to store visitor-specific data, please use the session data functions of your CMS.