PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.4.2
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.4.2
1.4.2 1.4.1 1.4.0 1.3.7 1.3.6 1.3.5 1.3.4 1.3.3 1.3.2 1.3.1 1.3.0 1.2.4 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 36 releases
← All changes | includes/class-plugin.php +137 -15 1.3.3 → 1.4.2 View file →
@@ -14,9 +14,9 @@
14 14 /**
15 15 * Data-schema version for one-time migrations, independent of the
16 16 * plugin version header. Bump when adding a step to maybe_upgrade().
17 17 */
18 - public const DATA_VERSION = '1.1.6';
18 + public const DATA_VERSION = '1.3.6';
19 19
20 20 private static $instance = null;
21 21
22 22 /** @var Usage_Tracker|null */
@@ -80,8 +80,11 @@
80 80 // Single-URL purge entry points — row actions, the edit-screen
81 81 // button and the admin-post handler the admin-bar item also uses.
82 82 Purge_Ui::boot();
83 83
84 + // While the page cache is off, every admin page says so (#594).
85 + Cache_Off_Notice::boot();
86 +
84 87 // Phase 0 architecture — managers + Free modules. v1 services
85 88 // (Cache/Minifier/Gzip) are NOT yet Modules; they'll be refactored
86 89 // in a follow-up PR with parity tests.
87 90 Conflict_Registry::boot();
@@ -93,17 +96,30 @@
93 96 // Integrations that clear OTHER plugins' caches of rendered output
94 97 // (Elementor's element cache + generated CSS). Registers a listener
95 98 // only; nothing runs until Cache::purge_render_caches() asks.
96 99 Render_Caches::boot();
97 - // Server_Caches needs no boot(): Cache::dispatch_purge_event() calls it
98 - // directly so a throwing third-party listener cannot skip it.
100 + // Forwarding needs no boot(): Cache::dispatch_purge_event() calls
101 + // Server_Caches::forward() directly so a throwing third-party listener
102 + // cannot skip it. Both built-in server-cache adapters live behind it —
103 + // LiteSpeed, and the nginx FastCGI cache reached through the host's
104 + // Nginx Helper install (Host_Page_Caches), which is why neither is
105 + // booted here. This boot() registers one listener only: the single
106 + // purge that runs after an import, which the nginx adapter's import
107 + // gate stands down in favour of.
108 + Server_Caches::boot();
99 109
100 - // Forward a full purge to a full-page cache owned by the WEB SERVER
101 - // (nginx FastCGI, via the host's Nginx Helper install). Registers a
102 - // listener on xspeed_after_purge_all only; it stands down unless
103 - // that cache is actually configured.
104 - Host_Page_Caches::boot();
110 + // Remembers the terms a post had before a save, so a narrow purge
111 + // can clear the category it left as well as the one it joined.
112 + Affected_Pages::boot();
113 + // Records which pages run a post list of their own (a page builder
114 + // grid, a related-posts block), so a narrow purge clears them too.
115 + Listing_Pages::boot();
105 116
117 + // Tell WP Statistics and Slimstat not to count the warmer, the
118 + // benchmark and the verifier as visitors. Record-time filters only;
119 + // see the class for why the tracking snippet itself is left alone.
120 + Self_Traffic::boot();
121 +
106 122 // Register Free modules via the same action xspeed-pro uses, so
107 123 // the bootstrap path is symmetric across tiers.
108 124 add_action( 'xspeed_register_modules', array( $this, 'register_free_modules' ) );
109 125
@@ -128,8 +144,38 @@
128 144 }
129 145 }
130 146
131 147 /**
148 + * Add the 1.3.6 tracking params to a saved ignored-params list.
149 + *
150 + * Only those names, and only when missing: anything else the site
151 + * removed stays removed. A site with no saved list already reads the new
152 + * defaults.
153 + */
154 + public static function add_new_ignored_params(): void {
155 + $option = Settings_Manager::OPTION_PREFIX . 'cache';
156 + $stored = get_option( $option, array() );
157 + if ( ! is_array( $stored ) || ! is_array( $stored['ignored_query_params'] ?? null ) ) {
158 + return;
159 + }
160 + $list = $stored['ignored_query_params'];
161 + // An empty list is a choice: every query string bypasses the cache.
162 + if ( empty( $list ) ) {
163 + return;
164 + }
165 + $missing = array_values( array_diff( \XSpeed\Modules\Cache\CacheModule::TRACKING_PARAMS_1_3_6, $list ) );
166 + if ( empty( $missing ) ) {
167 + return;
168 + }
169 + $stored['ignored_query_params'] = array_merge( $list, $missing );
170 + update_option( $option, $stored );
171 + // The drop-in keeps its own copy of the list next to the cache.
172 + if ( defined( 'XSPEED_CACHE_DIR' ) ) {
173 + Cache::sync_query_allowlist();
174 + }
175 + }
176 +
177 + /**
132 178 * Run version-gated data migrations exactly once per upgrade.
133 179 *
134 180 * Keyed on `xspeed_data_version` rather than the plugin version header
135 181 * so a migration can be added without forcing a release bump.
@@ -139,17 +185,25 @@
139 185 if ( version_compare( $current, self::DATA_VERSION, '>=' ) ) {
140 186 return;
141 187 }
142 188
189 + // Each step runs once, for the version that needs it. They used to
190 + // run on every bump, which would purge every site's static tree again
191 + // for a migration that has nothing to do with it.
192 +
143 193 // 1.1.2 — strip credential values recorded by earlier versions'
144 194 // settings change annotations (they're served by the trend endpoints).
145 - Activity_Log::redact_legacy_secrets();
195 + if ( version_compare( $current, '1.1.2', '<' ) ) {
196 + Activity_Log::redact_legacy_secrets();
197 + }
146 198
147 199 // 1.1.4 — earlier versions cached a failed loopback as "gzip is not
148 200 // active" for an hour, which showed up as a bogus server-config
149 201 // warning. Drop the stale answer so the fixed probe re-runs instead
150 202 // of the wrong verdict living on past the update (issue #18).
151 - delete_transient( 'xspeed_gzip_active' );
203 + if ( version_compare( $current, '1.1.4', '<' ) ) {
204 + delete_transient( 'xspeed_gzip_active' );
205 + }
152 206
153 207 // 1.1.6 — a `/?s=<term>` request used to write its results page into
154 208 // the static tree under the *searched-from* path, which for the usual
155 209 // query-form search is `/`. The web server then served that results
@@ -157,10 +211,50 @@
157 211 // Cache::store_static(), but an entry poisoned before the update
158 212 // outlives it: nothing purges on upgrade, and the static serve path
159 213 // never revalidates. Clear the tree once. The flat cache is keyed
160 214 // correctly and is deliberately left alone. (issue #191)
161 - Cache::purge_static_tree();
215 + if ( version_compare( $current, '1.1.6', '<' ) ) {
216 + $removed = Cache::purge_static_tree();
162 217
218 + /*
219 + * And tell anything caching in front of us, because the poisoned
220 + * entry is exactly the kind that reaches an edge: the web server
221 + * served it straight off disk as the homepage, so a CDN in front had
222 + * every opportunity to store it. Deleting our copy leaves that one
223 + * untouched, and the edge's lifetime is the longer of the two.
224 + *
225 + * Announced on `init` rather than here. This runs at
226 + * `plugins_loaded` 21, before an add-on has wired its purge
227 + * listeners, so firing it inline would announce to an empty room.
228 + * Priority 99 puts it after any reasonable `init` registration.
229 + *
230 + * Once per site, on the upgrade that clears the tree — never again,
231 + * since the data version is written immediately below.
232 + *
233 + * Through `Cache::announce_purge()` rather than a bare `do_action`,
234 + * because the purge-event contract (#348) is more than the payload:
235 + * it forwards to the server caches by direct call before the public
236 + * action runs, and it isolates listeners so one throwing add-on
237 + * cannot fatal the first admin request after an update. A raw
238 + * publish here would skip both and hand listeners the pre-contract
239 + * payload shape.
240 + */
241 + add_action(
242 + 'init',
243 + static function () use ( $removed ) {
244 + Cache::announce_purge( 'static cache repaired on upgrade', $removed );
245 + },
246 + 99
247 + );
248 + }
249 +
250 + // 1.3.6 — new click and campaign IDs in the default ignored list.
251 + // A site that ever saved the Cache panel has its own copy of the list,
252 + // which the new defaults never reach, so add them to it.
253 + if ( version_compare( $current, '1.3.6', '<' ) ) {
254 + self::add_new_ignored_params();
255 + }
256 +
163 257 update_option( 'xspeed_data_version', self::DATA_VERSION, false );
164 258 }
165 259
166 260 /**
@@ -268,8 +362,9 @@
268 362 // cache-coverage features (404 / search / feed / REST / rules /
269 363 // maintenance) into one sidebar sub-item (FBS-83633).
270 364 Module_Registry::register( new \XSpeed\Modules\CacheCoverage\CacheCoverageModule() );
271 365 Module_Registry::register( new \XSpeed\Modules\Fonts\FontsModule() );
366 + Module_Registry::register( new \XSpeed\Modules\TurboRender\TurboRenderModule() );
272 367 Module_Registry::register( new \XSpeed\Modules\ResourceHints\ResourceHintsModule() );
273 368 // AI Privacy (GDPR off-switch) ships in Free even though every AI
274 369 // *feature* is Pro — privacy is a right, not a paid tier. FEATURES.md
275 370 // §AI row 6 mandates it. Without this registration the module was dead
@@ -306,10 +401,11 @@
306 401 public function start_plugin_tracking(): void {
307 402 $this->usage_tracker = Usage_Tracker::get_instance(
308 403 XSPEED_FILE,
309 404 array(
310 - 'opt_in' => true,
311 - 'item_id' => defined( 'XSPEED_INSIGHTS_ITEM_ID' ) ? XSPEED_INSIGHTS_ITEM_ID : false,
405 + 'opt_in' => true,
406 + 'email_marketing' => true,
407 + 'item_id' => defined( 'XSPEED_INSIGHTS_ITEM_ID' ) ? XSPEED_INSIGHTS_ITEM_ID : false,
312 408 )
313 409 );
314 410 $this->usage_tracker->init();
315 411 }
@@ -435,8 +531,22 @@
435 531 * @param string $profile Settings::PROFILE_* — which profile a fresh
436 532 * install came up with, '' if not fresh.
437 533 */
438 534 do_action( 'xspeed_activated', $installed_by, $profile );
535 +
536 + /*
537 + * Announce the change to anything caching in front of us.
538 + *
539 + * Activation writes the default settings and activates modules, so
540 + * every URL on the site starts returning different HTML. A CDN
541 + * holding renders from before goes on serving them for their whole
542 + * lifetime, and nothing told it.
543 + *
544 + * Cheap on a fresh install — there is nothing to sweep — and the
545 + * case it exists for is reactivation on a site that has been running
546 + * for months behind an edge.
547 + */
548 + Cache::purge_all( 'plugin activated' );
439 549 }
440 550
441 551 /**
442 552 * Restore the cache drop-in right after THIS plugin is updated.
@@ -479,9 +589,14 @@
479 589
480 590 Cache::restore_dropin_if_enabled();
481 591 }
482 592
483 - public static function deactivate() {
593 + /**
594 + * @param bool $network_wide Whether a network admin deactivated the
595 + * plugin for every site (WordPress passes this
596 + * to deactivation hooks).
597 + */
598 + public static function deactivate( $network_wide = false ) {
484 599 // Drop-in + WP_CACHE constant are NOT touched here. WordPress
485 600 // upgrades run as deactivate → wipe files → install → activate,
486 601 // so removing those artifacts on every deactivate would silently
487 602 // disable caching after each plugin update. uninstall.php
@@ -488,9 +603,16 @@
488 603 // handles full teardown when the user actually removes the
489 604 // plugin; auto_heal() restores state on the next admin_init if
490 605 // the drop-in or WP_CACHE went missing for any other reason.
491 606 Cache::purge_all();
492 - Minifier::purge_minified();
607 + // purge_all() is site-scoped and no longer touches min/, so clear it
608 + // here. On a network where only this site is deactivating, the other
609 + // sites still link those files: drop this site's manifests only.
610 + if ( is_multisite() && ! $network_wide ) {
611 + Minifier::purge_manifests( Asset_Manifest::blog_id() );
612 + } else {
613 + Minifier::purge_minified();
614 + }
493 615 Gzip::apply( false );
494 616
495 617 Module_Registry::deactivate_all();
496 618 }