| @@ -145,9 +145,9 @@ | ||
| 145 | 145 | return array(); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function settings_schema(): array { |
| 149 | - return array( | |
| 149 | + $schema = array( | |
| 150 | 150 | 'cache_expiry' => array( |
| 151 | 151 | 'type' => 'int', |
| 152 | 152 | // Matches the wizard's Balanced preset, which is what a fresh |
| 153 | 153 | // install starts on — a shorter module default meant the two |
| @@ -276,8 +276,27 @@ | ||
| 276 | 276 | 'info_title' => __( 'Custom edge headers', 'xspeed' ), |
| 277 | 277 | 'info' => __( 'These replace the headers xSpeed would have picked for your CDN. Two baselines are still added underneath: a Cache-Control, and "X-Accel-Expires: 0" for a page cache running in nginx on your own server. Name either one yourself and yours is used instead. Values containing $, % or a backslash are dropped — the same pairs go into nginx and Apache directives, where those cannot be escaped safely. Content-Length, Content-Encoding, Content-Type, Transfer-Encoding, Set-Cookie and Location are refused.', 'xspeed' ) |
| 278 | 278 | ), |
| 279 | 279 | ); |
| 280 | + | |
| 281 | + // LiteSpeed-only opt-in (#509): meaningless on any other server, so | |
| 282 | + // the field only exists in the schema where it can act — elsewhere the | |
| 283 | + // stored value survives via preserved_keys(). Inserted right after | |
| 284 | + // mobile_separate, its sibling static-fast-path trade-off. | |
| 285 | + if ( \XSpeed\Server::LITESPEED === \XSpeed\Server::type() ) { | |
| 286 | + $litespeed = array( | |
| 287 | + 'litespeed_static_rewrite' => array( | |
| 288 | + 'type' => 'bool', | |
| 289 | + 'default' => false, | |
| 290 | + 'label' => __( 'LiteSpeed Static Fast Path', 'xspeed' ), | |
| 291 | + 'description' => __( 'Serve cache hits straight from the web server via .htaccess instead of the PHP drop-in. No PHP runs on a hit, so the saving depends on how quickly PHP answers on this host — a few milliseconds on a fast server, far more where PHP is the bottleneck. The trade: LiteSpeed cannot add the X-XSpeed-Cache header to statically served pages, and those hits are not counted in the dashboard hit ratio. Leave off to keep every hit visibly tagged and counted.', 'xspeed' ), | |
| 292 | + ), | |
| 293 | + ); | |
| 294 | + $pos = (int) array_search( 'mobile_separate', array_keys( $schema ), true ) + 1; | |
| 295 | + $schema = array_slice( $schema, 0, $pos, true ) + $litespeed + array_slice( $schema, $pos, null, true ); | |
| 296 | + } | |
| 297 | + | |
| 298 | + return $schema; | |
| 280 | 299 | } |
| 281 | 300 | |
| 282 | 301 | /** |
| 283 | 302 | * `mobile_separate_review` lives outside the schema: migration sets it |
| @@ -290,9 +309,18 @@ | ||
| 290 | 309 | * |
| 291 | 310 | * @return string[] |
| 292 | 311 | */ |
| 293 | 312 | public function preserved_keys(): array { |
| 294 | - return array( 'mobile_separate_review' ); | |
| 313 | + $keys = array( 'mobile_separate_review' ); | |
| 314 | + // On non-LiteSpeed servers the litespeed_static_rewrite field is not | |
| 315 | + // in the schema (see settings_schema()), so a schema-driven save | |
| 316 | + // would silently drop a value chosen while the site ran LiteSpeed. | |
| 317 | + // Preserve it so moving LiteSpeed → other → LiteSpeed keeps the | |
| 318 | + // user's choice. On LiteSpeed itself the schema owns the key. | |
| 319 | + if ( \XSpeed\Server::LITESPEED !== \XSpeed\Server::type() ) { | |
| 320 | + $keys[] = 'litespeed_static_rewrite'; | |
| 321 | + } | |
| 322 | + return $keys; | |
| 295 | 323 | } |
| 296 | 324 | |
| 297 | 325 | /** |
| 298 | 326 | * Seed per-module option from the legacy xspeed_options blob if we |