Cache plugins

The import copies live’s plugin settings to the staging site, including CDN, Cloudflare and firewall credentials, and the file sync copies config files that hold live’s paths. This page lists, per cache plugin, what the sync switches off, rewrites and clears on staging, and the problem each change prevents.

Without these changes, a person who clicks “Purge All” in the staging admin can purge the live Cloudflare zone, and a cache clear on staging can delete live’s cache folder. The settings are cleared right after the import, before any WordPress code runs on staging; the files are fixed right after the file sync. Both happen on staging only. The order is in how it works.

The behaviour described here comes from the code in internal/sync/: neutralize.go (settings), livepaths.go (files), w3tc.go, and postProcessCommands and pageCaches in sync.go (cache clears).

Each plugin below was installed on a test server with dummy credentials, synced, and then purged from the staging admin, with all outbound HTTP logged and blocked. The check was that no request reached a live service, no credential stayed on staging, and live’s cache files and keys stayed. The real WP Rocket plugin and a LiteSpeed Enterprise server were part of the tests. Comet Cache, Jetpack Boost, SiteGround Optimizer and NitroPack were checked by reading their source only.

Overview

“Settings” are options in the staging database. “Files” are copied files whose live paths are replaced. “Cleared” are staging cache folders, relative to wp-content/cache/ unless they start with wp-content/; <host> is the staging host. A dash means the sync does nothing for that plugin in that column.

Plugin Settings switched off on staging Files fixed Staging cache cleared Notes
LiteSpeed Cache Cloudflare switch, key, email, zone, name; QUIC.cloud key and key pair advanced-cache.php, object-cache.php Page cache purge through LiteSpeed Excluded: litespeed. Object cache: prefix flush.
WP Rocket Cloudflare, Sucuri sync, RocketCDN token; base URL rewritten advanced-cache.php wp-rocket, min, busting, critical-css, used-css, background-css, fonts
W3 Total Cache Cloudflare, CDN, full-site CDN, message bus; new instance_id; CDN queue emptied w3tc-config/*.php (same changes), advanced-cache.php, object-cache.php page_enhanced/<host>, page, minify, db, object Refuses a db-cluster-config.php that names live’s database.
WP Super Cache – wp-cache-config.php, advanced-cache.php supercache/<host>, meta, blogs, files wp-cache-*
WP Fastest Cache Cloudflare CDN entry, Varnish – all, wpfc-minified, wpfc-mobile-cache, wpfc-widget-cache, tmpWpfc
Powered Cache Cloudflare switch, token, key, email, zone; Redis failback flush flag advanced-cache.php powered-cache/<host>
WP-Optimize – advanced-cache.php; live’s per-host config deleted wpo-cache/<host>, wpo-minify Its purge can clear a shared object cache.
Breeze – breeze-config/*.php (paths and home URL), advanced-cache.php breeze, breeze-minification, breeze-extra Warns on CDN_SITE_TOKEN in staging wp-config.php.
Cache Enabler – advanced-cache.php; live’s per-host settings deleted cache-enabler/<host>
Comet Cache – – comet-cache/cache/https/<host>, comet-cache/cache/http/<host>
Swift Performance Cloudflare, MaxCDN; Memcached mode becomes disk cache mu-plugins/swift-performance-loader.php; stored paths in the database swift-performance/<host> Lite and Pro.
Autoptimize – autoptimize_404_handler.php autoptimize
SiteGround Optimizer – sgo-config.php sgo-cache
Jetpack Boost – advanced-cache.php page_optimize, wp-content/boost-cache/cache/<host> Excluded: boost-cache/cache.
Hummingbird Cloudflare Stored minify paths in the database wp-content/wphb-cache/cache/<host>, wp-content/wphb-cache/cache/mobile/<host> Excluded: wphb-cache/cache, wphb-logs. Redis: salt rule.
Super Page Cache Cloudflare keys, token, zone, rule and worker IDs – wp-content/wp-cloudflare-super-page-cache/<host>/fallback_cache Excluded: wp-cloudflare-super-page-cache. Warns on its constants.
Cloudflare plugin API key, email, cached domain name – – Warns on CLOUDFLARE_API_KEY, CLOUDFLARE_EMAIL.
Proxy Cache Purge Tag purges, purge queue – –
Nginx Helper – – – Warns when both sites use one cache folder.
NitroPack – advanced-cache.php –

Every plugin in this table is also skipped in the staging WP-CLI commands; see below.

How the cleanup works

Settings. An option is either set to an empty string (an empty value is “off” for these plugins’ switches and removes a stored credential), or rewritten key by key. Serialized PHP arrays are parsed and only the listed top-level keys change; a key that does not exist is not added. JSON values are parsed the same way. Options that are missing or empty are left alone.

Check before the sync. Before the export, every option and W3 Total Cache config file that will be rewritten is read from live and rewritten in memory. If one cannot be parsed, for example a serialized value with a broken length, the sync stops before any change on staging. The dry run shows this check as [check]. See troubleshooting.

Files. Live’s webroot is replaced by the staging webroot where it appears as a whole path prefix: followed by /, ' or ". advanced-cache.php and object-cache.php are fixed whichever plugin wrote them; the table lists them under the plugins that write one.

Cleared folders. The sync deletes the contents of each folder and keeps the folder. It never calls the plugin’s own purge function, because those functions also purge Cloudflare, a CDN, Varnish or the object cache. Each clear runs only when the plugin’s folder exists in the staging wp-content/plugins/. A failed clear is a warning.

Why the folders need clearing: most of them are under the excluded wp-content/cache, or keyed by the staging host, so rsync neither copies nor deletes them. They hold pages that staging built from its old database.

LiteSpeed Cache

The risk: LiteSpeed Cache answers a content event such as Elementor’s URL replace or CSS flush with a full purge. A full purge flushes the whole object cache, resets OPcache and purges the Cloudflare zone with the credentials in the database, which were live’s. The sync therefore never runs wp litespeed-purge all, and skips LiteSpeed Cache in every other WP-CLI command.

WP Rocket

The risks: an admin action on staging (a menu, widget or Elementor save) purges the Cloudflare zone, with no capability check. Sucuri purges have no capability check at all; before the fix, the post-processing purged live’s Sucuri firewall cache with live’s API key. The RocketCDN token lets the staging “Purge RocketCDN cache” button purge live’s CDN zone. Live’s base URL would start WP Rocket’s domain-change flow in the staging admin.

W3 Total Cache

W3 Total Cache keeps its settings in wp-content/w3tc-config/*.php (<?php exit; ?> followed by JSON), or in the w3tc_config_0 option when W3TC_CONFIG_DATABASE is on. The sync changes both: the options w3tc_config_0 and w3tc_config_0_preview after the import, and the files after the file sync.

Before the sync starts, it refuses when live’s wp-content/db-cluster-config.php names live’s database in quotes: the file sync would copy it, and staging’s db.php would send queries to live. See troubleshooting.

Varnish and other page cache settings are not changed.

WP Super Cache

The risk: wp_cache_clear_cache() trusts $cache_path. With live’s path, a clear on staging deleted live’s cache folder.

WP Fastest Cache

The risk: every WP Fastest Cache purge sends purge_everything to the zone stored in the option, with no host check, and sends PURGE /.* to the Varnish server. The sync never calls a WPFC purge function for the same reason.

Powered Cache

The risk: powered_cache_flush() purges the Cloudflare zone stored in its settings, so a purge in the staging admin purged live’s zone. The sync also never calls it, and only deletes the folder.

WP-Optimize

WP-Optimize’s purge calls wp_cache_flush(), which clears the whole Redis database or Memcached server when staging shares live’s. See object cache.

Breeze

Like WP-Optimize, Breeze’s purge calls wp_cache_flush().

Cache Enabler

The risk: Cache Enabler’s early engine falls back to the first file in its settings folder, so it could load live’s.

Comet Cache

Comet Cache is skipped in the WP-CLI commands. Its settings are not changed.

Swift Performance

Both swift-performance and swift-performance-lite.

The risks: clear_all_cache() purges the Cloudflare zone and MaxCDN, and in Memcached mode flushes the whole Memcached server. Without the fix, the loader made staging run live’s plugin, and staging wrote into live’s cache path.

Autoptimize

SiteGround Optimizer

The risk: with live’s path, SiteGround Optimizer on staging wrote pages into live’s cache folder.

Jetpack Boost

Hummingbird

Both hummingbird-performance and wp-hummingbird.

The risks: a full page cache clear (Elementor, a settings save) sends purge_everything to live’s zone, and page rule and APO calls change it. Without the fix, Hummingbird’s daily cleanup on staging deleted live’s minified CSS and JS by stored path.

Super Page Cache

Plugin folder wp-cloudflare-page-cache.

The risks: every staging purge sends purge_everything to cf_zoneid. A staging settings save or plugin update rewrites live’s Cloudflare Cache Rule to the staging host, or deletes it. Its purge also calls wp_cache_flush().

Cloudflare plugin

The sync never copies wp-config.php, so a constant there was set on staging by hand, and the database cleanup cannot remove it. Remove it, or make sure it holds credentials for a staging zone only.

Proxy Cache Purge

Plugin folder varnish-http-purge.

The risk: tag purges ban by tag with no host check, and staging has live’s post IDs, so a save on staging would ban live’s pages. URL purges are by host and are left on.

Nginx Helper

“Purge Cache” in the staging admin deletes the whole folder, live’s pages included. Give staging its own fastcgi_cache_path in the Nginx config and its own RT_WP_NGINX_HELPER_CACHE_PATH in the staging wp-config.php. See servers.

NitroPack

NitroPack is skipped in the WP-CLI commands. Its connection settings are not changed, so the staging site keeps live’s NitroPack site ID and secret. Disconnect NitroPack on staging by hand.

Other changes

Plugins skipped in WP-CLI

Every WP-CLI command on the staging site runs with --skip-plugins= and this list:

litespeed-cache, wp-rocket, w3-total-cache, wp-super-cache, wp-fastest-cache,
sg-cachepress, breeze, cloudflare, hummingbird-performance, nitropack,
wp-optimize, autoptimize, swift-performance, swift-performance-lite,
cache-enabler, comet-cache, powered-cache, object-cache-pro,
wp-cloudflare-page-cache, wp-hummingbird, nginx-helper, varnish-http-purge,
jetpack-boost, atec-cache-apcu, docket-cache, sqlite-object-cache, wp-redis,
redis-cache, flying-press

These plugins hook content and cache events to purge caches or a CDN, and the staging database holds live’s settings for those purges. A search-replace or an Elementor CSS flush would otherwise run them. The one exception is the LiteSpeed page purge, which needs LiteSpeed Cache loaded and skips the others.

--skip-plugins does not skip must-use plugins or drop-ins: object-cache.php and advanced-cache.php still load. That is why the drop-in is probed and its paths are fixed before post-processing.

The list is sideEffectPlugins in internal/sync/sync.go. When the staging admin is used later, the plugins load normally, with the cleaned settings.

This page is docs/cache-plugins.md in the repository.

wp-stage-sync is an independent, open-source project. It is not affiliated with, endorsed by, or sponsored by WordPress, WordPress.org, the WordPress Foundation, or Automattic. The WordPress® trademark is the property of the WordPress Foundation.