Clear Cache
New in 3.22.1. After a code, style or content change, a page cache can keep showing visitors the old page until it expires. clear-cache clears every cache layer it finds on the site, so the change shows at once. Content is not changed.
Enabled by default. Requires manage_options. Its switch is in the Performance & Security section of the WordPress tab on EMCP Tools → Tools.
emcp-tools/clear-cache
Section titled “emcp-tools/clear-cache”Input (all optional):
layers: only these layer ids, such as["elementor", "wp-rocket"]. Default: every layer found on the site.object_cache: also flush the object cache (Redis, Memcached). Defaultfalse.
Returns: results, one entry per layer with layer, label, status and detail; purged, the number of layers cleared or queued; and detected, the layer ids active on the site.
Each layer reports its own status:
| Status | Meaning |
|---|---|
purged | The cache plugin’s clear call ran. |
queued | The clear happens on the next request. LiteSpeed clears through a response header; Kinsta accepts a request and clears its server cache. |
skipped | You named a layer that is not active on this site. |
failed | The clear call returned an error or failed. detail says why. |
Layers
Section titled “Layers”| Layer id | Plugin or host | How it is cleared |
|---|---|---|
elementor | Elementor | Regenerates Elementor’s CSS files. |
wp-rocket | WP Rocket | rocket_clean_domain() and rocket_clean_minify(). |
litespeed | LiteSpeed Cache | The litespeed_purge_all action (queued). |
w3-total-cache | W3 Total Cache | w3tc_flush_all(). |
wp-super-cache | WP Super Cache | wp_cache_clear_cache(). |
wp-fastest-cache | WP Fastest Cache | wpfc_clear_all_cache(). |
autoptimize | Autoptimize | autoptimizeCache::clearall(). |
breeze | Breeze (Cloudways) | The breeze_clear_all_cache action. |
siteground | SiteGround Speed Optimizer | sg_cachepress_purge_everything(). |
wp-optimize | WP-Optimize | Its page cache purge(). |
cache-enabler | Cache Enabler | The cache_enabler_clear_complete_cache action. |
kinsta | Kinsta | The purge Kinsta’s own MU plugin runs. |
Each plugin’s method was checked against that plugin’s code and run on a test site. Kinsta publishes no PHP API for clearing caches, so EMCP calls the purge Kinsta’s MU plugin uses for its admin bar button; it has not been verified on a live Kinsta site yet. If a layer reports failed, use the plugin’s or host’s own Clear cache button.
Clearing caches after a code change
Section titled “Clearing caches after a code change”add-code-snippet, update-code-snippet, add-custom-css and add-custom-js take clear_cache: true. They then clear the caches after saving and add the same report under cache in their answer.
