Skip to main content

Purging cache via the API

Purging clears cached content so the next visitor gets fresh bytes from your origin. This guide is task-focused; the exact request/response contract lives in the API reference. All examples authenticate with an API key in the X-API-Key header.

How purge works (read this first)โ€‹

A purge is asynchronous. The API enqueues the work and responds 200 immediately with a job count โ€” that means the jobs were queued, not that the cache has already cleared. The background worker then applies the purge to every active hostname, across all Origin Shields first and then all healthy PoP nodes.

200 means queued, not cleared

A 200 response with a jobCount confirms the purge was accepted and queued. It is fire-and-forget โ€” there is no callback or status to confirm the cache actually cleared. Allow a short propagation window before re-testing.

Single purgeโ€‹

POST /api/property/{id}/purge

Body:

{ "type": "All", "value": null, "matchType": null }

Purge typesโ€‹

typeMeaningvalue
AllPurge everything for the propertyOmitted / ignored
ExtensionPurge files with a given extensionRequired (for example jpg; case-insensitive, a leading dot is ignored)
PathPurge a specific pathRequired (for example /images/logo.png)
RegexPurge by patternRequired (the pattern)

type is required and case-insensitive. There is no separate wildcard or tag field โ€” wildcard-style purging is done with type: "Regex".

An Extension value does not distinguish case and may carry a leading dot: jpg, .jpg and JPG all purge photo.jpg and PHOTO.JPG. The API stores it trimmed, without the dot and in lower case.

A Path value is a URL path as you would request it, with an optional query string. The path may be percent-encoded or not (/blog/caf%C3%A9 and /blog/cafรฉ purge the same object), and the query string goes through the property's query string mode exactly like a request does: parameters the mode ignores are dropped and their order does not matter, so purging /page?utm_source=x&id=1 removes the object a visit to that URL would be served from.

All four types also cover entries cached under a custom cache key (cache_key with headers or cookies): a Path, Extension or Regex purge removes every header and cookie variant of the matching URLs, and Path matches the URL both with and without its query string.

Match type (Regex only)โ€‹

matchType is honored only when type is Regex. For Extension and Path it is ignored.

matchTypeBehavior
equalsExact match
containsSubstring match
starts_withPrefix match
ends_withSuffix match
regexRegular-expression match (default when omitted or blank)

With regex the value is a PCRE pattern, and the API checks it before queuing anything: an invalid pattern returns 400 (Invalid regex pattern: โ€ฆ) in a single purge and lands in rejected in a batch. Besides patterns that do not compile, the check refuses some the edge could compile, with the same rules as regex match operators: nested unbounded quantifiers such as (a+)+ or (\w+){2,30} (they can take exponential time, ReDoS) and possessive quantifiers such as a++ (write an atomic group, (?>a+), instead). The other match types compare the value as text, with its query string read as parameters โ€” see the next section.

What a pattern is compared withโ€‹

A Regex purge is checked against every cached object of the property. What it sees of each object is its path, percent-decoded as in rules, followed by ? and its query string as the cache stores it:

  • only the parameters the property's query string mode keeps (none with ignore_all), and never the signature parameters (pdm_token, pdm_expires, pdm_path) of a path protected by signed URLs, except on an HLS or DASH manifest (.m3u8, .mpd), where they are always kept;
  • sorted by parameter name, comparing bytes: uppercase letters sort before _, and _ before lowercase letters (/p?a=1&Z=2&_x=3 is stored as /p?Z=2&_x=3&a=1); repeated values of one parameter keep the order the visitor sent;
  • each name=value exactly as the visitor sent it (not decoded), except # and |, which are stored as %23 and %7C;
  • no ? at all when no parameter is kept.

A visit to /page?utm_source=x&b=2&a=1 on a property that ignores utm_source is stored as /page?a=1&b=2.

You do not have to write the value in that form. With equals, starts_with, ends_with and contains, the query string in your value is read as a list of parameters and normalized the same way: parameters the property ignores are dropped and their order does not matter.

When the value contains ? it is split into a path and its parameters:

matchTypePath partParameters
equalsThe object's path is exactly thisThe object has exactly these parameters
starts_withThe object's path is exactly thisThe object has all of these; it may have more
ends_withThe object's path ends with this (may be empty, as in ?id=5)The object has exactly these parameters
containsThe object's path ends with this (may be empty)The object has all of these; it may have more

With starts_with and contains the last parameter of the value may be incomplete: /search?q=fo matches /search?q=foo&page=2. A value ending in ? is a URL with an empty query string, which is served from the object without one: starts_with /p? removes /p as well as every /p?โ€ฆ.

ValuematchTypeRemoves the object stored as
/p?b=2&a=1equals/p?a=1&b=2
/p?utm_source=x&id=7equals/p?id=7, when the property ignores utm_source
/p?b=2starts_with/p?a=1&b=2, /p?b=2&c=3, /p?b=20
.css?v=2ends_with/assets/site.css?v=2, but not /assets/site.css?t=1&v=2
?id=5containsevery object with a parameter id=5โ€ฆ, whatever its path and its other parameters

When the value has no ? it is compared as text with the path and stored query string described above. That is all a path needs (starts_with /blog/, contains /product/), and a single parameter is found wherever it sorts (contains id=5). Two cases also match when the parameters are stored in another order:

  • ends_with: the object has every parameter of the value; the first one may be incomplete at its start. id=5 matches /p?id=5&z=1.
  • contains with two or more parameters (an & in the value): the object has all of them; the first may be incomplete at its start and the last at its end. b=2&a=1 matches /p?a=1&b=2&c=3.

Parameters the property ignores are dropped here too, and a value left with none matches nothing: on a property that ignores utm_source, contains utm_source=x removes no object. An ends_with such as .css matches objects whose path ends in .css and no query string is stored, and also objects with a parameter whose value ends in .css (/load?file=site.css). To purge a file type whatever its query string, use an Extension purge.

A value made only of ignored parameters matches by its path

Parameters the property ignores are not part of any cached object, so they cannot narrow a purge. With ? in the value, the path decides: equals /page?utm_source=x removes /page, and contains /page?utm_source=x removes every object whose path ends in /page.

A value left with neither a path nor a parameter would describe every object of the property, so it is only compared as text: contains ? removes the objects stored with a query string, and contains ?utm_source=x removes nothing. The same goes for a regex with nothing before \? and nothing kept after it. To empty the whole property, use All.

Without ?, a first parameter that starts in the middle of its name is filtered by the property's query string mode as if that partial name were the whole name. With except or only it can then miss objects: ends_with e=x meant for code=x, or contains d=5&b=2 meant for id=5&b=2, is checked against the mode as parameter e or d. Start the value at a parameter boundary instead: &code=x or the full code=x, or ?code=x with the meaning of a value with ? described above.

A path whose cache rule sets cache_key.include_query_string to false is stored without its query string, so a value with ? does not reach it. Purge it by its path, without ?, or with a Path purge.

Query strings in a regex patternโ€‹

A regex pattern is applied as written to that same text โ€” path, ?, stored query string โ€” so a pattern that spells out several parameters has to list them in alphabetical order and leave out the ones the property ignores.

There is one exception, for the usual case of a literal query string: when the pattern has an escaped question mark (\?) followed only by literal text, optionally ending in $, the text after \? is read as parameters and normalized like the other match types.

  • ^/p\?b=2&a=1$ removes the object stored as /p?a=1&b=2. On a property that ignores utm_source, ^/p\?utm_source=x&id=7$ removes /p?id=7.
  • With the final $ the object has exactly those parameters. Without it, it has all of them and may have more, and the last one may be incomplete.
  • The part of the pattern before \? stays a regular expression and has to match up to the end of the path: ^/(es|en)/p\?a=1$.
  • Escaped punctuation counts as literal text: \?v=1\.2$.

The exception does not apply, and the pattern is applied exactly as written, when any of these is true:

  • there is no \? (a question mark written as [?] does not count), or the \? is inside a group: ^/p(\?a=1)?$;
  • the text after \? uses regex syntax โ€” ., *, +, ?, (, [, {, |, a $ that is not the last character, or a class such as \d or \w: ^/p\?id=\d+$;
  • the pattern has an alternative (|) outside a group, inline flags such as (?i), or a \Qโ€ฆ\E quote.

For those patterns, write the query string as it is stored. ^/p\?a=\d+&b=2$ matches /p?b=2&a=1 because the object is stored as /p?a=1&b=2; ^/p\?b=\d+&a=1$ matches nothing. To match one parameter wherever it sorts, use ^/p\?(.*&)?b=2(&|$).

On a property with image optimization, w, h, q, format and fit are part of the stored query string of image URLs whatever the query string mode, so they count in a pattern as well.

Examplesโ€‹

Purge everything:

curl -X POST https://api.paradarum.com/api/property/123/purge \
-H "X-API-Key: pdm_YOUR_RAW_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "type": "All" }'

Purge a single path:

curl -X POST https://api.paradarum.com/api/property/123/purge \
-H "X-API-Key: pdm_YOUR_RAW_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "type": "Path", "value": "/images/logo.png" }'

Purge by extension:

curl -X POST https://api.paradarum.com/api/property/123/purge \
-H "X-API-Key: pdm_YOUR_RAW_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "type": "Extension", "value": "jpg" }'

Purge by pattern with a match type:

curl -X POST https://api.paradarum.com/api/property/123/purge \
-H "X-API-Key: pdm_YOUR_RAW_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{ "type": "Regex", "value": "/blog/", "matchType": "starts_with" }'

Success responseโ€‹

{
"succeeded": true,
"message": "Purge request accepted. 12 jobs queued across 2 shields + 4 PoPs.",
"data": { "jobCount": 12, "shields": 2, "nodes": 4, "hostnames": 1 }
}

Batch purgeโ€‹

Combine several instructions into one round-trip.

POST /api/property/{id}/purge/batch
curl -X POST https://api.paradarum.com/api/property/123/purge/batch \
-H "X-API-Key: pdm_YOUR_RAW_KEY_HERE" \
-H "Content-Type: application/json" \
-d '{
"items": [
{ "type": "All" },
{ "type": "Path", "value": "/index.html" },
{ "type": "Extension", "value": "css" },
{ "type": "Regex", "value": "^/assets/", "matchType": "regex" }
]
}'

Each item has the same shape as a single purge and is validated independently. Valid items are queued; invalid ones are reported back in rejected, each with its index and a reason.

A batch takes at most 500 items; split larger purges into several batches. Every item counts against the per-account limit, valid or not. When a batch includes All, the property is purged once and the other valid items are not queued separately, because All already covers them (they still count in accepted).

{
"succeeded": true,
"message": "...",
"data": {
"jobCount": 6,
"accepted": 3,
"rejected": [{ "index": 1, "reason": "Value is required..." }],
"shields": 2,
"nodes": 4,
"hostnames": 1
}
}
One bad item does not fail the batch

A single invalid item never fails the whole request โ€” it lands in rejected[] while the valid items proceed. The batch only returns 400 when every item is invalid, the items array is empty, or it has more than 500 items.

Guards and error responsesโ€‹

A purge can be blocked before anything is queued. Branch on the HTTP status and read the message.

StatusWhen it happensExample message
400Missing/invalid type or value; a Regex pattern the edge cannot compile; empty batch or more than 500 items; no active hostnamesNo active hostnames found for this property.
403Property is disabled or suspendedThis property is currently {status}... Configuration changes are not allowed until it is re-enabled.
404Property not found, or owned by another accountProperty not found.
429More than 1,000 purge items in a minute for the account (a single purge counts 1, a batch 1 per item); wait the seconds in the Retry-After headerToo many purge items: at most 1000 every 60 s per account (a single purge counts 1, a batch 1 per item). Retry in 42 s.
500No healthy, traffic-enabled PoP nodes availableNo active cache nodes found.
Requirements for a purge to queue

The property must have at least one Active hostname (otherwise 400) and at least one healthy PoP node (otherwise 500). A disabled or suspended property rejects purges with 403.

Rate limitโ€‹

Each account can purge up to 1,000 items per minute, counted over a sliding 60-second window: a single purge counts 1 and a batch counts 1 per item, including items that end up in rejected. A batch above 500 items is refused with 400 and does not count.

Above the limit the purge returns 429 and queues nothing. The Retry-After header says how many seconds to wait until there is room for that same request again (a 500-item batch may wait longer than a single purge), so a client that waits that long and retries gets through:

HTTP/1.1 429 Too Many Requests
Retry-After: 42

Automate from WordPress or PrestaShopโ€‹

CMS purge plugins call these same endpoints โ€” typically purge after a single post or product changes, and purge/batch to clear several paths at once.

Paradarum ships official, ready-to-install plugins that do exactly this for you โ€” no code required:

Use a dedicated key per site

Create a separate, descriptively named API key for each site (for example Production WordPress). If a site is decommissioned or a key leaks, revoke just that key without disrupting your other integrations.