mainwp-cache-control category. All use the mainwp/ namespace on your MainWP Dashboard.
What You’ll Learn
- Read cached site status and global cache settings
- Set global and site-specific purge policies
- Check stored Cloudflare credentials
- Purge one site’s cache and interpret the result for each cache layer
Prerequisites
- WordPress 6.9 or later on the MainWP Dashboard site
- MainWP Dashboard with Abilities API support; use version 6.2 or later for the
input_jsonexamples below - Cache Control 5.3 or later, active on MainWP Dashboard
- An authenticated WordPress user with
manage_options, access to Cache Control, and access to the target sites - A configured cache plugin or Cloudflare integration on each site you want to purge
see_server_information; global settings and credential validation require manage_dashboard_settings; site policy changes and purges require edit_sites. Site-specific calls also check access to that site, and the status list omits sites the user cannot access.
Available Abilities
Discover the abilities and their schemas:
site_id: a positive integer such as 1, or its decimal string form such as "1". Domains, URLs, zero, and strings with leading zeros are not accepted. These abilities reject extra input properties.
Read One Site’s Cache Status
Ability:mainwp/get-site-cache-control-status-v1Method: GET
current_configuration reflects settings stored in MainWP Dashboard, including global inheritance. The policy modes determine the two configured_*_enabled values.
cached_child_observation contains the cache solution and purge timestamp last reported by MainWP Child. cache_solution is an empty string when unavailable, and last_reported_purge_at is a Unix timestamp or 0 when unavailable.
This read does not contact MainWP Child or Cloudflare, trigger a purge, or refresh observations.
live is always false, and child_application_status is always unknown. A configured setting does not prove it has reached the Child site. Sync the site separately to refresh its cached observations; a reported purge timestamp alone does not confirm provider success.List Site Cache Statuses
Ability:mainwp/list-site-cache-control-statuses-v1Method: GET
The response contains
items, next_cursor, and has_more. Each item has the same structure as the single-site status response above. Sites are processed in ascending ID order.
While has_more is true, pass the returned next_cursor as the next request’s cursor. Do not stop because a page has fewer than limit items or is empty: permission checks can omit sites from that page. When pagination is complete, has_more is false and next_cursor is null.
Read Global Cache Configuration
Ability:mainwp/get-global-cache-control-configuration-v1Method: GET This ability accepts no input properties.
cloudflare_auth_method is token or email_key. credential_state describes storage for the selected method:
This read does not decrypt, migrate, or validate credentials. It returns no API key, token, or email address. With no saved enablement settings, both enablement flags are
false.
Set Global Cache Policy
Ability:mainwp/set-global-cache-control-policy-v1Method: POST Set both required boolean fields. This example enables automatic cache purging and disables global Cloudflare purging:
previous and current objects with both flags, a changed boolean, and sync_status: "not_requested". Calling it with the existing values returns changed: false.
This changes only the two global enablement settings. It does not change credentials, authentication method, bulk request limits, or request delay. Site-specific overrides continue to apply.
Set Site Cache Policy
Ability:mainwp/set-site-cache-control-policy-v1Method: POST All three input fields are required:
site_id, auto_purge_mode, and cloudflare_mode. The two mode fields must be integers and use different mappings:
This example makes site
1 inherit both global settings:
site_id, previous and current objects with both modes, a changed boolean, and sync_status: "not_requested". Credentials are unchanged.
Neither policy ability syncs or purges sites. Sync the affected sites separately after changing settings. A successful save confirms the Dashboard settings were stored; it does not confirm their application on MainWP Child. Configure credentials through the Cache Control settings before enabling Cloudflare purging.
Validate Cloudflare Credentials
Ability:mainwp/validate-cloudflare-credentials-v1Method: GET
Selecting No (disabled for this site) skips validation and returns
disabled. When the site inherits global credentials, the diagnostic can still validate them even if global Cloudflare purging is switched off.
valid confirms the credentials passed Cloudflare’s credential check. It does not confirm access to the site’s zone or permission to purge it. See Cloudflare API token permissions.
Legacy credentials awaiting migration can return malformed here. Review and save the credentials in Cache Control settings before checking again; this diagnostic does not perform migration.
Purge One Site’s Cache
Ability:mainwp/purge-site-cache-v1Method: POST This requests a purge using the configuration already applied on MainWP Child. It does not first sync newly saved Dashboard settings.
overall even when the HTTP request succeeds:
Both
plugin_cache and cloudflare contain attempted and result_basis:
last_purged_at is the most recent plugin or Cloudflare purge timestamp in the Child response, or 0 when unavailable. It may be an earlier timestamp and does not override overall.
Keep MainWP Child up to date. This ability requires structured purge results, including result_basis. A Child response without those fields returns mainwp_cache_control_purge_result_invalid; the cache may still have been purged, so check the site’s logs before retrying.
Read the Last Purge Outcome
Ability:mainwp/get-site-cache-purge-outcome-v1Method: GET
site_id, available, observed_at, overall, plugin_cache, and cloudflare. The outcome and layer fields use the values described above. observed_at is the stored outcome’s observation time, not the provider’s purge timestamp.
This reads the structured outcome stored on MainWP Dashboard without contacting the Child site. If no valid structured outcome is stored, it returns available: false, observed_at: 0, overall: "unknown", and both layers as unattempted. This does not mean the site has never been purged: older logs or a last-purged timestamp may exist without a structured outcome.
Error Handling
Standard authentication, schema, and method errors follow the Abilities API error reference. Cache Control can also return:
Policy write errors include
data.rollback_failed. If it is true, read the current settings and resolve the save failure before syncing. After a purge transport, result, or storage error, inspect the site and logs before retrying because a purge may already have occurred.
Related Resources
- Cache Control - Configure caching, Cloudflare, and manual purge workflows
- Abilities API Overview - Authentication, input formats, discovery, and errors
- Sites Abilities - Find site IDs and sync sites after changing settings
