Cloudflare tutor

A morning desk for Kotha · Gold Coast

· Australia/Brisbane · Lesson

Cache: how Cloudflare keeps copies close to your visitors

Cache (CDN caching, Cache-Control, and purge)

What it is

When a hostname is proxied (the orange cloud from lesson 1), Cloudflare can keep a copy of a file in its data centres and hand that copy to the next visitor instead of asking your origin server again. That stored copy is the cache. By default Cloudflare caches static files by their extension, such as images, CSS, JavaScript, and fonts, and does not cache ordinary HTML pages unless you tell it to.

Two sets of instructions decide what happens. The Cache-Control header on a response, such as "public, max-age=300", says who may store it and for how many seconds. Cloudflare’s own settings, mainly Cache Rules in the dashboard (under Caching; the wording may differ slightly), can override or extend that for a hostname or path. Every proxied response carries a cf-cache-status header such as HIT (served from the cache), MISS (fetched fresh, then stored), DYNAMIC (not eligible for caching), or BYPASS.

Workers are a special case. A Worker runs in front of the cache, so the page it builds is not stored at the edge automatically. A Worker only uses the edge cache if its code asks for it, through the Cache API (caches.default) or by fetching an origin with caching options. A Cache-Control header on a Worker’s own response mostly tells the visitor’s browser how long to keep it.

Why it matters

Caching is why a small site can feel fast in Brisbane and anywhere else: the copy is served from a nearby Cloudflare location, and your origin, whether a Hostinger VPS, Pages, or another host, gets fewer requests. For a site on a VPS that is real protection against slowdowns when a page is shared widely.

It is also the most common reason a change seems not to appear. You deploy a new version, but a browser or the edge is still holding the old copy until its max-age runs out. Knowing about Cache-Control, cf-cache-status, and purge lets you tell "my deploy failed" apart from "I am looking at a cached copy".

The safety rule is simple: never cache anything personal or private, such as a logged-in page, a form result, or anything with patient details. Cache public, identical-for-everyone content only.

On your account

This tutor (cloudflare-tutor on cloudflare.kosan.xyz) sends cache-control: public, max-age=300 on its pages, and its responses carry no cf-cache-status header, because the Worker builds each page itself and does not use the Cache API. So Cloudflare’s edge does not store these pages; your browser may keep a page for up to 5 minutes, which is why a brand-new lesson can take a few minutes to show unless you refresh hard. That stays true after today.

A site on your Hostinger VPS proxied through kosan.xyz or drkotha.com is the classic edge-cache shape: its logo, CSS, and JavaScript would show cf-cache-status: HIT after the first visit, while its HTML shows DYNAMIC unless a Cache Rule says otherwise. After replacing an image with the same filename, a Purge by URL clears just that file.

Nothing in this lesson adds a Cache Rule, changes a cache setting, or purges anything on kosan.xyz or drkotha.com.

Do this yourself

These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.

  1. In your browser, open https://cloudflare.kosan.xyz, open the developer tools Network tab, reload, click the page request, and read its response headers to find cache-control and confirm there is no cf-cache-status; then do the same on one image or CSS file from a proxied site you own on kosan.xyz or drkotha.com and note whether it says HIT, MISS, or DYNAMIC, and reload once more to see whether it changes. Then, read only, open the Caching section of the kosan.xyz zone in the dashboard and look at Configuration and Cache Rules without changing anything. Do not purge everything, change caching levels, or add Cache Rules on any live zone.