A purge removes cached content from every edge node that caches the zone, generally in less than a second. It is audited but not versioned, so it takes a reason and an optional simulation, but no expected version. The token needs the Tech role; the dashboard can also create a token that can only purge one zone's cache, which suits a CI pipeline.
The body has exactly one of these keys, with at most 100 values:
| Key | Purges |
|---|---|
purge_everything: true | Everything cached for the zone. |
files | These URLs of the zone, with all their variants. |
prefixes | Every URL that starts with this host/path. |
hosts | Everything cached for these names. |
tags | Every response that carried one of these Cache-Tag values. |
import { OpenWAF } from "./openwaf.ts";
const owf = new OpenWAF();
const { items = [] } = await owf.listZones();
const zone = items.find((z) => z.name === "example.com");
if (!zone?.id) throw new Error("example.com not found");
const body = { files: ["https://www.example.com/app.js", "https://www.example.com/styles.css"] };
// Optional: check what will be purged (the values come back normalised).
const preview = await owf.purgeCache({ zone: zone.id, body }, { reason: "Deploy 42", dryRun: true });
console.log("will purge", preview.kind, preview.values, preview.warnings);
const done = await owf.purgeCache({ zone: zone.id, body }, { reason: "Deploy 42" });
console.log("purge", done.seq);from openwaf import OpenWAF
owf = OpenWAF()
zone = next(z for z in owf.list_zones()["items"] if z["name"] == "example.com")
body = {"files": ["https://www.example.com/app.js", "https://www.example.com/styles.css"]}
# Optional: check what will be purged (the values come back normalised).
preview = owf.purge_cache(zone=zone["id"], body=body, reason="Deploy 42", dry_run=True)
print("will purge", preview["kind"], preview["values"], preview["warnings"])
done = owf.purge_cache(zone=zone["id"], body=body, reason="Deploy 42")
print("purge", done["seq"])Check that it reached the edge
listCachePurges / list_cache_purges lists the zone's purges of the last 7 days with, for each one, how many caching edge nodes serve the zone (nodes) and how many have already applied it.