Purge the cache

Purge cached URLs, prefixes, names or tags from the OpenWAF edge after a deployment, from TypeScript or Python.

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:

KeyPurges
purge_everything: trueEverything cached for the zone.
filesThese URLs of the zone, with all their variants.
prefixesEvery URL that starts with this host/path.
hostsEverything cached for these names.
tagsEvery response that carried one of these Cache-Tag values.
purge.ts
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);

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.

Last updated:

↑↓ to navigate↵ to openesc to close