Skip to content

Purge a website's page cache

POST /api/v2/shared-hosting/{accountId}/page-cache/actions/purge

Empty a website’s stored page cache. Use it when visitors get an old or broken copy of a page while you see the real site when logged in. The call deletes the contents of wp-content/cache/ in the website’s folder. That is where WordPress cache plugins such as WP-Optimize, WP Rocket, WP Super Cache and W3 Total Cache keep their pages. It also empties the account’s lscache/ folder, the web server’s page cache for every website on the account. The folders themselves stay, as do any .htaccess, index.php and index.html in them. The cache fills again on the next visits. The response lists what was emptied and what was skipped. The account must be active and on cPanel.

Authentication: An API key with the scopes write:hosting and console:services. About keys and scopes

Request

Path parameters

accountIdstringrequired
The web hosting account ID (acct_…).

Body (optional)

domainstring
The website, as a full host name on the account such as shop.example.com. Default: the account’s main domain.

Example

POST /api/v2/shared-hosting/{accountId}/page-cache/actions/purge
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/page-cache/actions/purge" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json"

Responses

200 What was emptied and what was skipped.

Response 200
{
"domain": "example.com",
"purged": [
{
"path": "public_html/wp-content/cache",
"entries": 148
}
],
"skipped": [
{
"path": "lscache",
"reason": "not_present"
}
]
}
Response fields
domainstring
The website whose cache was emptied.
purgedarray of object
Cache folders that were emptied.
pathstring
The folder, relative to the account’s home folder.
entriesinteger
Entries deleted. 0 means the folder was already empty. At least 0.
skippedarray of object
Folders or entries that were not emptied.
pathstring
The folder or entry, relative to the account’s home folder.
reasonstring
not_present: the folder does not exist. delete_failed: the entry could not be deleted. One of not_present, delete_failed.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400domain is not a full host name (invalid_request).
401Unauthorized. Authentication is required.
403The key lacks a scope or the account is not active. domain_not_owned: the domain is not on this account.
404Not found. The resource does not exist or is not owned by the caller.
409The account is not on cPanel (account_not_eligible_cpanel).
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502The cache folder could not be read or emptied right now (upstream_failed). Try again later.