| @@ -97,9 +97,23 @@ | ||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $server_type = \XSpeed\Server::type(); |
| 100 | 100 | if ( \XSpeed\Server::APACHE === $server_type || \XSpeed\Server::LITESPEED === $server_type ) { |
| 101 | - if ( ! \XSpeed\Cache::rewrite_installed() ) { | |
| 101 | + // Only call the block "missing" when it is genuinely absent by | |
| 102 | + // accident. When static_rewrite_allowed() deliberately refused it, | |
| 103 | + // "toggle Enable Cache off and on" cannot reinstall anything — | |
| 104 | + // the same condition suppresses the write and auto_heal() strips | |
| 105 | + // the block again on the next admin load. Explain the real cause. | |
| 106 | + $block_reason = \XSpeed\Cache::static_rewrite_block_reason(); | |
| 107 | + if ( 'no_mod_headers' === $block_reason ) { | |
| 108 | + $result['label'] = __( 'xSpeed is serving cache hits through PHP', 'xspeed' ); | |
| 109 | + $result['status'] = 'recommended'; | |
| 110 | + $result['description'] = '<p>' . esc_html__( 'Caching is working — hits are served by the xSpeed drop-in and tagged X-XSpeed-Cache: HIT (php). The faster .htaccess fast path is off because Apache\'s mod_headers module is not loaded, without which a static hit could not be tagged or counted. Enable mod_headers (a2enmod headers on Debian/Ubuntu, then restart Apache) to shave roughly 20-30ms off each cache hit.', 'xspeed' ) . '</p>'; | |
| 111 | + } elseif ( 'mobile_separate' === $block_reason ) { | |
| 112 | + $result['label'] = __( 'xSpeed static rewrite is off (Separate Mobile Cache)', 'xspeed' ); | |
| 113 | + $result['status'] = 'recommended'; | |
| 114 | + $result['description'] = '<p>' . esc_html__( 'Separate Mobile Cache is on, so cache hits are served by the PHP drop-in to keep per-device HTML correct. Turn Separate Mobile Cache off if your site serves the same HTML to every device to regain the faster static path.', 'xspeed' ) . '</p>'; | |
| 115 | + } elseif ( \XSpeed\Server::APACHE === $server_type && ! \XSpeed\Cache::rewrite_installed() ) { | |
| 102 | 116 | $result['label'] = __( 'xSpeed .htaccess rewrite block is missing', 'xspeed' ); |
| 103 | 117 | $result['status'] = 'recommended'; |
| 104 | 118 | $result['description'] = '<p>' . esc_html__( 'Without the static-rewrite block, cache hits go through the PHP drop-in (~85ms TTFB) instead of the web server (~5-15ms). Toggle Enable Cache off and on in xSpeed to reinstall the block.', 'xspeed' ) . '</p>'; |
| 105 | 119 | } |
| @@ -126,11 +140,11 @@ | ||
| 126 | 140 | } |
| 127 | 141 | |
| 128 | 142 | public function ui_metadata(): array { |
| 129 | 143 | return array( |
| 130 | - 'label' => 'Health', | |
| 144 | + 'label' => __( 'Health', 'xspeed' ), | |
| 131 | 145 | 'icon' => 'HeartPulse', |
| 132 | - 'description' => 'Diagnostics, hit ratio, and recent cache activity.', | |
| 146 | + 'description' => __( 'Diagnostics, hit ratio, and recent cache activity.', 'xspeed' ), | |
| 133 | 147 | // Health is the single host page for all Insights (FBS-83633): |
| 134 | 148 | // a Recommendations action card + Cache / Visitors / PageSpeed |
| 135 | 149 | // tabs. HealthPanel renders the Free cache diagnostics (the old |
| 136 | 150 | // HealthCard) as the Cache tab and hosts the Pro insight panels |
| @@ -160,8 +174,9 @@ | ||
| 160 | 174 | array( |
| 161 | 175 | 'name' => 'xspeed health', |
| 162 | 176 | 'callback' => array( $this, 'cli_handler' ), |
| 163 | 177 | 'shortdesc' => 'Print diagnostic checks + cache stats + recent activity.', |
| 178 | + 'ai_hint' => 'Full diagnostic sweep: what is misconfigured or degraded on this site right now, plus cache stats and recent activity. The best FIRST call for open-ended "why is my site slow" or "is anything wrong" questions.', | |
| 164 | 179 | 'synopsis' => array(), |
| 165 | 180 | ), |
| 166 | 181 | array( |
| 167 | 182 | 'name' => 'xspeed recommend', |
| @@ -166,8 +181,9 @@ | ||
| 166 | 181 | array( |
| 167 | 182 | 'name' => 'xspeed recommend', |
| 168 | 183 | 'callback' => array( $this, 'cli_recommend' ), |
| 169 | 184 | 'shortdesc' => 'List ranked next-best-action recommendations, or apply one by id.', |
| 185 | + 'ai_hint' => 'The ranked list of what to do next to make this site faster, and the way to apply one. Use when asked "what should I improve" or "what\'s the biggest win" — each item is actionable and ordered by impact.', | |
| 170 | 186 | 'synopsis' => array( |
| 171 | 187 | array( |
| 172 | 188 | 'type' => 'positional', |
| 173 | 189 | 'name' => 'action', |