PluginProbe
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN / 1.4.1
xSpeed Cache: AI-Powered Performance Hub with MCP, Caching & CDN v1.4.1
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 1.1.2 All 35 releases
← All changes | includes/modules/Cache/CacheModule.php +157 -10 1.3.7 → 1.4.1 View file →
@@ -225,9 +225,10 @@
225 225 '/wc-api',
226 226 '/edd-api',
227 227 '/wp-login',
228 228 ),
229 - 'item_type' => 'string',
229 + // `path`: kept as typed, percent-encoded slugs included.
230 + 'item_type' => 'path',
230 231 'label' => __( 'Excluded URLs', 'xspeed' ),
231 232 'description' => __( 'Pages whose URL matches a line here are never cached. Plain text matches anywhere (/cart). A pattern with * matches from the start of the path: /cart/* matches /cart/items but not /shop/cart/items. ~ starts a regex.', 'xspeed' ),
232 233 ),
233 234 'excluded_cookies' => array(
@@ -265,8 +266,16 @@
265 266 'default' => true,
266 267 'label' => __( 'Clear cache after updates', 'xspeed' ),
267 268 'description' => __( 'Clear the page cache when a plugin, theme or WordPress is updated, so visitors never get old pages with broken asset links.', 'xspeed' ),
268 269 ),
270 + 'purge_affected_only' => array(
271 + 'type' => 'bool',
272 + 'default' => true,
273 + 'label' => __( 'Clear only the pages a change affects', 'xspeed' ),
274 + 'description' => __( 'When you publish, edit or delete a post, clear that post, the pages that list it and its feeds instead of the whole site. Pages with a post grid from a page builder, a block plugin or the theme are noted as they are built and cleared when the change can affect their list; turn this off if a grid still shows an old list.', 'xspeed' ),
275 + 'info_title' => __( 'Which pages are cleared', 'xspeed' ),
276 + 'info' => __( 'The post, its old address if it moved, the home page, the blog page, its categories, tags and author pages with every page of each, the date archives, feeds, the posts next to it, pages that show a Latest Posts or Query Loop block, directly or in a synced pattern, and pages noted running a post grid of their own (a page builder, block plugin, related-posts or theme list) that the change can affect. If your theme shows a list that can be on any page, and the change alters it, xSpeed clears the whole site instead: a Recent Posts, Archives or Calendar widget, a post list block, or a latest-posts grid from a page builder or plugin (usually a new post, or an edit to one of the newest few it shows), a page list or menu (a page published, withdrawn, renamed or moved), or a Categories or Tag Cloud list (a post moved to other categories or tags).', 'xspeed' ),
277 + ),
269 278 'mobile_separate' => array(
270 279 'type' => 'bool',
271 280 'default' => false,
272 281 'label' => __( 'Separate mobile cache', 'xspeed' ),
@@ -277,9 +286,9 @@
277 286 'default' => 'auto',
278 287 'options' => array( 'auto', 'off', 'cloudflare', 'fastly', 'varnish', 'nginx', 'akamai', 'cloudfront', 'google', 'keycdn', 'bunny', 'sucuri', 'incapsula', 'generic', 'custom' ),
279 288 'option_labels' => array(
280 289 'auto' => 'Detect automatically',
281 - 'off' => 'Off — send nothing',
290 + 'off' => 'Off (no edge lifetime or cache tags)',
282 291 'cloudflare' => 'Cloudflare',
283 292 'varnish' => 'Varnish',
284 293 'nginx' => 'nginx proxy cache',
285 294 'cloudfront' => 'Amazon CloudFront',
@@ -305,9 +314,9 @@
305 314 'label' => __( 'CDN or proxy in front', 'xspeed' ),
306 315 'description' => __( 'Tells your CDN or proxy not to store pages xSpeed does not cache. Leave on Detect automatically unless you know your provider.', 'xspeed' ),
307 316 'advanced' => true,
308 317 'info_title' => __( 'Cache in front of this site', 'xspeed' ),
309 - 'info' => __( 'Naming your provider narrows the headers to the one it reads. Detect automatically works it out per request and otherwise sends a set every cache ignores unless it understands it, so it is safe not to know. Run "wp xspeed cache edge" to see what was detected and what gets sent.', 'xspeed' )
318 + 'info' => __( 'Naming your provider narrows the headers to the one it reads. Detect automatically works it out per request and otherwise sends a set every cache ignores unless it understands it, so it is safe not to know. Off stops the edge lifetime and cache tags. When an add-on that manages the edge, such as a Cloudflare Enterprise add-on, is active, the "don\'t store" headers for logged-in, cart and search pages still go out. Run "wp xspeed cache edge" to see what was detected and what gets sent.', 'xspeed' )
310 319 ),
311 320 'edge_custom_headers' => array(
312 321 'type' => 'list',
313 322 'default' => array(),
@@ -514,9 +523,9 @@
514 523 'synopsis' => array(
515 524 array(
516 525 'type' => 'assoc',
517 526 'name' => 'type',
518 - 'description' => 'What to clear: all (default), page, object, cloudflare, cdn — or a group name (edge). Comma-separate to clear several.',
527 + 'description' => 'What to clear: all (default), page, object, cloudflare, xcloud (sites with xCloud\'s purge plugin), cdn — or a group name (edge). Comma-separate to clear several.',
519 528 'optional' => true,
520 529 ),
521 530 array(
522 531 'type' => 'assoc',
@@ -535,14 +544,14 @@
535 544 ),
536 545 array(
537 546 'name' => 'xspeed cache',
538 547 'callback' => array( $this, 'cli_handler' ),
539 - 'shortdesc' => 'Inspect the Cache module: `status` (settings), `inventory` (which pages are cached, and how old), `size` (where the disk usage goes), `purge-log` (what cleared the cache, when and why), `purge-url <url>` to clear one page, `recheck-rewrite` to re-run the static-rewrite probe, or `nginx-config` to print the unified nginx server-block for pasting into a vhost, or `edge` to show which cache is in front of the site and what xSpeed tells it. To clear the whole site use `wp xspeed purge`.',
548 + 'shortdesc' => 'Inspect the Cache module: `status` (settings), `inventory` (which pages are cached, and how old), `size` (where the disk usage goes), `purge-log` (what cleared the cache, when and why), `purge-url <url>` to clear one page, `recheck-rewrite` to re-run the static-rewrite probe, or `nginx-config` to print the unified nginx server-block for pasting into a vhost, or `edge` to show which cache is in front of the site and what xSpeed tells it, or `listings` to show which pages were recorded running a post list of their own (cleared by a narrow purge when a save may change that list). To clear the whole site use `wp xspeed purge`.',
540 549 'synopsis' => array(
541 550 array(
542 551 'type' => 'positional',
543 552 'name' => 'action',
544 - 'options' => array( 'status', 'inventory', 'size', 'purge-log', 'purge-url', 'recheck-rewrite', 'nginx-config', 'edge' ),
553 + 'options' => array( 'status', 'inventory', 'size', 'purge-log', 'purge-url', 'recheck-rewrite', 'nginx-config', 'edge', 'listings' ),
545 554 'optional' => true,
546 555 ),
547 556 array(
548 557 'type' => 'positional',
@@ -551,9 +560,9 @@
551 560 ),
552 561 array(
553 562 'type' => 'assoc',
554 563 'name' => 'limit',
555 - 'description' => 'Rows to print for inventory / purge-log. Default 20.',
564 + 'description' => 'Rows to print for inventory / purge-log (default 20), or sample pages for listings (default 5).',
556 565 'optional' => true,
557 566 ),
558 567 array(
559 568 'type' => 'assoc',
@@ -903,8 +912,15 @@
903 912 // HIT (php). See Cache::qualify_rewrite_probe().
904 913 $probe = \XSpeed\Cache::qualify_rewrite_probe( \XSpeed\Cache::recheck_static_rewrite() );
905 914 $blocked = '' !== (string) $probe['block_reason'];
906 915
916 + // Whether the installed rules are the ones these settings
917 + // generate. Reported before the verdict below because it is the
918 + // question someone running this command has just acted on — they
919 + // pasted a block and want to know if it took — and because
920 + // "active" is true for a stale block too.
921 + $this->cli_report_rules_state( (array) ( $probe['rules'] ?? array() ) );
922 +
907 923 if ( $probe['active'] ) {
908 924 \WP_CLI::success( 'Static rewrite is active — the web server is serving cache hits directly.' );
909 925 return;
910 926 }
@@ -927,11 +943,21 @@
927 943 \WP_CLI::error( 'Usage: wp xspeed cache purge-url <url-or-path>' );
928 944 return;
929 945 }
930 946 $cause = isset( $assoc['cause'] ) && '' !== trim( (string) $assoc['cause'] ) ? trim( (string) $assoc['cause'] ) : 'CLI';
931 - $removed = \XSpeed\Cache::purge_url( $url, $cause );
947 + $result = \XSpeed\Cache::purge_url_reported( $url, $cause );
948 + $removed = $result['removed'];
949 + $forwarded = implode( ', ', $result['forwarded'] );
932 950 if ( $removed > 0 ) {
933 - \WP_CLI::success( sprintf( 'Purged %d cache file(s) for %s', $removed, $url ) );
951 + \WP_CLI::success(
952 + '' === $forwarded
953 + ? sprintf( 'Purged %d cache file(s) for %s', $removed, $url )
954 + : sprintf( 'Purged %d cache file(s) for %s, and sent the purge to %s', $removed, $url, $forwarded )
955 + );
956 + } elseif ( '' !== $forwarded ) {
957 + // xSpeed's own cache held nothing, but a cache in front of
958 + // PHP took the purge: that copy is the one visitors get.
959 + \WP_CLI::success( sprintf( 'Sent the purge for %s to %s. xSpeed\'s own cache held no copy.', $url, $forwarded ) );
934 960 } else {
935 961 \WP_CLI::log( sprintf( 'No cache entries found for %s (already cold, or the URL never cached).', $url ) );
936 962 }
937 963 return;
@@ -956,8 +982,13 @@
956 982 $this->cli_edge();
957 983 return;
958 984 }
959 985
986 + if ( 'listings' === $action ) {
987 + $this->cli_listings( isset( $assoc['limit'] ) ? $limit : 5 );
988 + return;
989 + }
990 +
960 991 $opts = Settings_Manager::get( self::SLUG );
961 992 \WP_CLI::log( 'cache_expiry ' . $opts['cache_expiry'] . 'h' );
962 993 \WP_CLI::log( 'excluded_urls ' . count( $opts['excluded_urls'] ) . ' entries' );
963 994 foreach ( $opts['excluded_urls'] as $u ) {
@@ -1036,15 +1067,131 @@
1036 1067 \WP_CLI::log( sprintf( ' %s: %s', $name, $value ) );
1037 1068 }
1038 1069 }
1039 1070
1071 + // The same bake the drop-in gets, so it asks no per-page question.
1072 + $variant = \XSpeed\Cache::query_variant_edge_headers();
1073 +
1040 1074 \WP_CLI::log( '' );
1041 - \WP_CLI::log( 'X-XSpeed-Edge-Hold names why a response was held: bypass, bypass-shape, miss, mobile-split or pending. No header means nothing was held.' );
1075 + if ( array() === $variant ) {
1076 + \WP_CLI::log( 'A cached page requested with an ignored parameter (?utm_source=x) gets the same headers as without one. It is held only where a cache in front was detected, and with Separate Mobile Cache on every page is held already.' );
1077 + } else {
1078 + \WP_CLI::log( 'On a cached page requested with an ignored parameter (?utm_source=x), a cached search or a query-form feed:' );
1079 + foreach ( $variant as $name => $value ) {
1080 + \WP_CLI::log( sprintf( ' %s: %s', $name, $value ) );
1081 + }
1082 + }
1042 1083
1084 + \WP_CLI::log( '' );
1085 + \WP_CLI::log( 'X-XSpeed-Edge-Hold names why a response was held: bypass, bypass-shape, miss, mobile-split, pending or query-variant. No header means nothing was held.' );
1086 +
1043 1087 if ( 'cloudflare' === $answer['provider'] ) {
1044 1088 \WP_CLI::log( '' );
1045 1089 \WP_CLI::log( 'A Cloudflare Cache Rule whose Edge TTL is "Ignore cache-control header and use this TTL" overrides all of the above. Use "Respect origin TTL" on that rule if pages are still being stored.' );
1046 1090 }
1091 + }
1092 +
1093 + /**
1094 + * `wp xspeed cache listings`: the pages recorded running a post list
1095 + * outside the main loop, which a narrow purge adds when a save may
1096 + * change that list.
1097 + *
1098 + * For measuring how wide that set gets on a real site: close to every
1099 + * page means a narrow purge saves little there.
1100 + *
1101 + * @param int $samples Pages to print.
1102 + */
1103 + private function cli_listings( int $samples ): void {
1104 + $narrow = ! empty( Settings_Manager::get( self::SLUG )['purge_affected_only'] );
1105 + $stats = \XSpeed\Listing_Pages::stats( $samples );
1106 + $limit = \XSpeed\Affected_Pages::LIMIT;
1107 +
1108 + \WP_CLI::log( 'narrow purge ' . ( $narrow ? 'on' : 'off' ) );
1109 + \WP_CLI::log( 'recording ' . ( \XSpeed\Listing_Pages::enabled() ? 'on' : 'off' ) );
1110 + \WP_CLI::log( 'directory ' . $stats['dir'] );
1111 +
1112 + \WP_CLI::log( '' );
1113 + \WP_CLI::log( 'Newest-N lists (' . count( $stats['specs'] ) . ' of ' . \XSpeed\Listing_Pages::SPEC_CAP . '): a change to one of the newest N clears the whole site.' );
1114 + foreach ( $stats['specs'] as $spec ) {
1115 + \WP_CLI::log( sprintf( ' newest %d of %s%s', $spec['n'], implode( ', ', $spec['types'] ), $spec['sticky'] ? ', sticky posts first' : '' ) );
1116 + }
1117 +
1118 + \WP_CLI::log( '' );
1119 + \WP_CLI::log( sprintf( 'Pages with other lists: %d recorded (%d files, cap %d); %d posts in the shown-on index.', $stats['pages'], $stats['files'], \XSpeed\Listing_Pages::CAP, $stats['posts'] ) );
1120 + foreach ( $stats['types'] as $type => $counts ) {
1121 + \WP_CLI::log(
1122 + sprintf(
1123 + ' %-14s %d pages, %d not precise%s',
1124 + $type,
1125 + $counts['all'],
1126 + $counts['loose'],
1127 + $counts['loose'] > $limit
1128 + ? ' (over ' . $limit . ' not precise: any change to a post of this type clears the whole site)'
1129 + : ( $counts['all'] > $limit ? ' (over ' . $limit . ': a change that is not a plain edit clears the whole site)' : '' )
1130 + )
1131 + );
1132 + }
1133 +
1134 + if ( null !== $stats['full'] ) {
1135 + \WP_CLI::warning(
1136 + sprintf(
1137 + 'The record is full, and pages listing %s went unrecorded: a change to a post of those types clears the whole site until a save finds the record under the cap.',
1138 + implode( ', ', array_map( 'strval', (array) ( $stats['full']['types'] ?? array( 'any' ) ) ) )
1139 + )
1140 + );
1141 + }
1142 + if ( array() === $stats['samples'] ) {
1143 + return;
1144 + }
1145 + \WP_CLI::log( '' );
1146 + foreach ( $stats['samples'] as $record ) {
1147 + \WP_CLI::log(
1148 + sprintf(
1149 + ' %s [%s] %s',
1150 + $record['url'],
1151 + implode( ', ', $record['types'] ),
1152 + $record['precise'] ? 'precise, ' . count( $record['ids'] ) . ' post(s) shown' : 'not precise'
1153 + )
1154 + );
1155 + }
1156 + }
1157 +
1158 + /**
1159 + * Say which version of the cache rules the server is running.
1160 + *
1161 + * The generated block stamps every static hit with a hash of itself, and
1162 + * the probe reads that back — the only way to tell what someone actually
1163 + * pasted into a config WordPress cannot open. `stale` names the settings
1164 + * that moved since, where we can tell, because "re-paste the block" with
1165 + * no reason attached is what makes people ignore it.
1166 + *
1167 + * @param array $rules Cache::rules_state() output.
1168 + */
1169 + private function cli_report_rules_state( array $rules ): void {
1170 + $state = (string) ( $rules['state'] ?? '' );
1171 +
1172 + if ( 'current' === $state ) {
1173 + \WP_CLI::log( 'Cache rules: current — the installed rules are the ones these settings generate.' );
1174 + return;
1175 + }
1176 + if ( 'stale' === $state ) {
1177 + $changed = array_filter( array_map( 'strval', (array) ( $rules['changed'] ?? array() ) ) );
1178 + \WP_CLI::log(
1179 + '' === implode( '', $changed )
1180 + ? 'Cache rules: stale — a different version of the rules is installed. Re-paste the block.'
1181 + : sprintf(
1182 + 'Cache rules: stale — a different version of the rules is installed (%s changed since). Re-paste the block.',
1183 + implode( ', ', $changed )
1184 + )
1185 + );
1186 + return;
1187 + }
1188 + if ( 'absent' === $state ) {
1189 + \WP_CLI::log( 'Cache rules: absent — no xSpeed rules are installed, or they predate the version marker.' );
1190 + return;
1191 + }
1192 +
1193 + \WP_CLI::log( 'Cache rules: unknown — the probe could not read a rules marker back from this server.' );
1047 1194 }
1048 1195
1049 1196 /** `wp xspeed cache inventory [--limit=N]` — which pages are cached, and how old. */
1050 1197 private function cli_inventory( int $limit ): void {