Caching

The part that actually makes it fast.

Everything else is plumbing. Caching is what stops your server doing the same work for the thousandth visitor that it did for the first.

Your site

How it works, in one paragraph

The first time someone asks an edge location for a file, it does not have it, so it fetches it from your server and keeps a copy. Everyone after that is served the copy. Your server sees one request instead of a thousand, and the visitor gets an answer from a machine near them rather than one on another continent. A cache hit ratio of 90% means nine in ten requests never touched your server at all.

Your site

Three settings decide almost everything about how well this works.

  1. How long to keep a copy

    Your server suggests a lifetime in its headers. Smart cache works one out when your server does not send anything sensible, and you can override both when you know better than either.

  2. What counts as the same file

    The cache key. By default a URL is a file — but you can make the cache vary by query string, cookie, device type or country when those genuinely produce different content, and ignore them when they do not.

  3. When to throw a copy away

    Expiry handles it normally. Purging handles it now — a whole zone, one URL, or everything carrying a cache tag, cleared everywhere within seconds of you clicking.

Beyond the basics

Settings for when the default is not right

Keeping more, fetching less

CapabilityWhat it does for you
Perma-cacheWrites a permanent copy into storage so files never fall out of cache. Your origin is fetched once, ever, rather than once per location per expiry. For a site with large static files this is the difference between an origin that is busy and one that is idle.
Origin shieldOne nominated location fetches from your server and feeds every other location from there. Instead of 121 locations each asking your origin for a fresh copy, one does.
Request coalescingA hundred simultaneous requests for an uncached file become one request to your origin. This is what stops a cache expiry turning into a traffic spike on your server.
Stale while revalidateServes the slightly stale copy immediately and refreshes it in the background, so nobody ever waits for your origin to answer.

Large files and media

CapabilityWhat it does for you
Cache slicingSplits big files into chunks that are cached separately. A viewer who skips to the middle of a video pulls that chunk, not the whole file.
Range request supportPartial downloads and video seeking work properly, served from cache rather than the origin.

Control

CapabilityWhat it does for you
Cache error responsesCache your 404s briefly so a bot hammering a missing URL does not hammer your server instead.
Cache versioningBump a version to invalidate everything at once without purging file by file.
Query string handlingIgnore tracking parameters so utm_source does not create a hundred copies of the same page.
Straight answers

About caching

My site is dynamic. Is caching useless?

Almost never. Even a logged-in application serves static assets — CSS, JavaScript, images, fonts — and those are usually most of the bytes on a page. Cache those and leave the HTML uncached, and you have still moved the majority of your traffic off your server.

How do I stop a page being cached?

Send a no-store header from your origin, or add an edge rule matching the path. Login pages, carts and admin areas should be excluded, and any sensible setup excludes them from the start.

How do I know it is working?

The statistics page shows your cache hit ratio. Below 50% means something is stopping caching — usually cookies, or a query string creating unique URLs. Tell us the domain and we will look at it with you.

What is a good hit ratio?

For a static or mostly-static site, above 90%. For a busy application with lots of personalised HTML, 60-70% is realistic and still means most of your bytes never touched your server.

How fast does a purge take effect?

Seconds, everywhere. There is no waiting period and no limit on how often you can purge.

Not sure how to configure it?

Send us the domain and we will look at what your site is sending, tell you what is stopping it caching, and set it up with you. That is not a paid service.

Get more out of your cache

Already have a zone? Tell us the domain and we will review its caching with you.