Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Whenever you use our CDN with perma-cache, you'll often see a few headers related to caching. We'll review each header and how the various combinations work.

cdn-cache: This header shows the cache status on our CDN edge servers. Usually, you'd see HIT (Loaded from the CDN cache) or MISS (Loaded from perma-cache or origin).

perma-cache: This shows the status of the files in perma-cache. The status can be either HIT (Loaded from our storage) or MISS (Loaded from origin).

There's usually 4 combinations of the above 2 headers you'll see:

  1. cdn-cache: MISS / perma-cache: MISS
  2. cdn-cache: HIT / perma-cache: MISS
  3. cdn-cache: MISS / perma-cache: HIT
  4. cdn-cache: HIT / perma-cache: HIT

Let's go over each one and explain what it means.

cdn-cache: MISS / perma-cache: MISS

If both headers show "MISS", it's because neither the CDN edge nor the perma-cache had the file in cache, and the request comes from your origin. However, it will make the perma-cache try to pick up the file from the origin asynchronously.

Performance-wise, this is the slowest combination.

cdn-cache: HIT / perma-cache: MISS

In this case, the file loads from the CDN edge server. But what about the perma-cache: MISS header? In a case like this, it means that when the CDN edge fetched the file, it was not yet in the perma-cache. From a CDN edge server perspective, it is considered an upstream server; it keeps (and caches) this header and will show in the header output for as long as the file stays in the CDN edge cache.

In fact, in a cache where the cdn-cache header is a HIT, the perma-cache header should be ignored since it may, in most cases, not reflect the actual perma-cache status!

Performance-wise, this, together with combination number 4, is the fastest.

cdn-cache: MISS / perma-cache: HIT

Here the CDN edge server didn't have the file in the cache, so it fetched it from the closest perma-cache location available based on your storage replication settings.

This combination of headers will often show when files are infrequently accessed but will be fetched from the closest storage location based on your perma-cache's storage zone replication settings.

Performance-wise this is slightly slower than combination 2 and 4.

cdn-cache: HIT / perma-cache: HIT

In this case, both the CDN edge server has it cached, and when the CDN edge server fetched the file, the server fetched it from the perma-cache.

Performance-wise, as mentioned before, this is the fastest combination, like combination 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment