Cloudflare cache purge (POST /zones/{zone_id}/purge_cache). Send one kind of target per call. Success means Cloudflare accepted the purge; per-request item limits and rate limits depend on the plan (see https://developers.cloudflare.com/cache/how-to/purge-cache/). The token needs the Zone → Cache Purge permission.

Context Vars

Optional
  • cloudflare.token

Functions

purge

fn (zone-id: Str, body: Map): Map
fn (zone-id: Str, body: Map, opts: Map): Map

POST /zones/{zone_id}/purge_cache with an explicit body: one of {files}, {tags}, {hosts}, {prefixes}, or {purge_everything: true}. Returns {id}.

purge-everything

fn (zone-id: Str): Map
fn (zone-id: Str, opts: Map): Map

Purge the zone's entire cache. Expect a burst of origin traffic afterwards.

purge-hosts

fn (zone-id: Str, hosts: Vec<Str>): Map
fn (zone-id: Str, hosts: Vec<Str>, opts: Map): Map

Purge everything cached for the given hostnames (e.g. ["www.example.com"]).

purge-prefixes

fn (zone-id: Str, prefixes: Vec<Str>): Map
fn (zone-id: Str, prefixes: Vec<Str>, opts: Map): Map

Purge by URL prefix: hostname plus path, no scheme, query, or fragment (e.g. ["www.example.com/blog/"]).

purge-tags

fn (zone-id: Str, tags: Vec<Str>): Map
fn (zone-id: Str, tags: Vec<Str>, opts: Map): Map

Purge everything whose Cache-Tag response header carries any of tags.

purge-urls

fn (zone-id: Str, urls: Vec): Map
fn (zone-id: Str, urls: Vec, opts: Map): Map

Purge specific URLs. Each entry is a URL string, or {url, headers} when the cache key varies on request headers (CF-Device-Type, CF-IPCountry, Accept-Language, Origin).

Example

::cloudflare::cache/purge-urls(zone-id, ["https://example.com/", "https://example.com/pricing"])