Purging
A purge removes cached files from every location within about fifteen seconds, and the next request for them is fetched from your origin. Purge one file by its full URL, a whole folder by a URL ending in *, every file your origin tagged with a cache tag, or everything the zone has cached. From the API each is one call: see Purging in the API reference.
Purge a file or a folder#
On the zone page, Purge opens a side panel with three choices: Everything, A file or folder and A tag. A file or folder takes a full URL on one of the zone's hostnames:
| You enter | What is purged |
|---|---|
https://cdn.example.com/videos/intro.mp4 | That one file |
https://cdn.example.com/videos/* | Everything under /videos/, at any depth |
https://cdn.example.com/videos/ep1* | Every path that starts /videos/ep1: ep1.mp4, ep10/ and so on |
https://cdn.example.com/* | Everything, the same as purging the zone |
A folder is a URL whose path ends in *, with one * and nothing after it: no query string. It purges every query string of every file under the path.
What a file purge matches#
- The path and query string.
/intro.mp4and/intro.mp4?v=1are two files, and purging one leaves the other, unless the zone's Query string setting makes them one copy. - Every hostname of the zone at once, whether they share one copy or hold one each.
- Every compressed and uncompressed copy, and every piece of a large file.
- The scheme and the port in the URL do not matter. The hostname has to be one of the zone's own, or the purge is refused, and the URL is at most 2,048 characters.
Purge by tag#
Your origin can name the groups a file belongs to in a Cache-Tag header, comma separated, or a Surrogate-Key header, space separated. Purging one of those tags removes every cached file that carried it, under every hostname, whatever its path:
Cache-Tag: product-123, catalogue, home
Surrogate-Key: product-123 catalogue home- Tags are not case-sensitive, and each is up to 128 characters with no spaces or commas.
- A file keeps up to 512 characters of tags. A file whose tags are longer is removed by a purge of any tag of the zone, so a purge never leaves it behind.
- Viewers are never sent these headers; they stay between your origin and the cache.
- A file cached before your origin tagged it carries no tags until it is fetched again.
How fast#
The purge panel shows the purge landing as a moving bar that then reads Purged everywhere; the API reports the same as COMPLETE. A location that is offline applies the purge as soon as it comes back, before it serves anything. A location that has applied a purge never takes the purged copy back from another location or from the zone's Home PoP that has not applied it yet: until they have, the file is fetched from your origin.
Purging less#
The next request after a purge is a MISS, stored again under the lifetime your origin gives it or the zone's Cache expiration time; a purge does not touch your origin and does not pre-fetch anything. Two things make most purges unnecessary. A file whose name or query string changes with each version, app.3f9c.css or intro.mp4?v=2, is a new file to the cache the moment you deploy it, and the old one expires on its own. And a short lifetime on files you replace in place, from a max-age or from the zone's Cache expiration time, bounds how stale they can be without any purge: a bound rather than a promise, because an expired copy may still be served for up to 24 hours while the refresh behind it runs. Purges are free. The API's rate limit is the only limit on them, and the cost of one is that the next viewers of a busy file are served from your origin, one fetch per location rather than one per viewer.