| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * XSPEED_DROPIN |
| 4 | - * XSPEED_DROPIN_VERSION: 8 | |
| 4 | + * XSPEED_DROPIN_VERSION: 9 | |
| 5 | 5 | * Drop-in cache loader. Serves cached HTML before WordPress fully boots. |
| 6 | 6 | * |
| 7 | 7 | * Bump XSPEED_DROPIN_VERSION whenever this file's serve logic changes so |
| 8 | 8 | * Cache::ensure_dropin_current() reinstalls it on existing sites (the |
| @@ -318,8 +318,42 @@ | ||
| 318 | 318 | // PHP-served cache hit (the ~85ms fallback path). The nginx static |
| 319 | 319 | // rewrite sends "HIT (nginx)" for the fast 5-15ms path; same header, |
| 320 | 320 | // distinct value so you can tell which layer served the page. |
| 321 | 321 | header( 'X-XSpeed-Cache: HIT (php)' ); |
| 322 | + | |
| 323 | + // Edge/CDN headers decided by Cache::edge_headers_for(). No filter | |
| 324 | + // can run here — plugins are not loaded — so Cache::install_dropin() | |
| 325 | + // bakes the resolved pairs into the literal below and re-bakes them | |
| 326 | + // on every cache settings save. | |
| 327 | + // | |
| 328 | + // An un-substituted placeholder means this file was copied straight | |
| 329 | + // from a source checkout: it stays a string, is_array() rejects it, | |
| 330 | + // and the HIT is served with no edge headers rather than a fatal. | |
| 331 | + $xspeed_edge_headers = '@@XSPEED_EDGE_HEADERS@@'; | |
| 332 | + | |
| 333 | + // A page whose answer differs from the site-wide one carries its own | |
| 334 | + // pairs in the sidecar. It REPLACES the baked set rather than adding | |
| 335 | + // to it: the two describe the same response, and merging would leave | |
| 336 | + // the baked lifetime in place beside the hold meant to overrule it. | |
| 337 | + if ( isset( $xspeed_meta['edge_headers'] ) && is_array( $xspeed_meta['edge_headers'] ) ) { | |
| 338 | + $xspeed_edge_headers = $xspeed_meta['edge_headers']; | |
| 339 | + } | |
| 340 | + | |
| 341 | + // The one setting this file reads for itself. Everything else about | |
| 342 | + // the edge answer is baked, because re-deriving it here would mean | |
| 343 | + // loading options before WordPress exists. `off` is the exception | |
| 344 | + // because it is the emergency switch: when something is wrong in | |
| 345 | + // production at three in the morning, waiting for a re-bake is not an | |
| 346 | + // answer. Any other value is a pin, and a pin is already baked in. | |
| 347 | + if ( defined( 'XSPEED_EDGE_PROVIDER' ) && 'off' === strtolower( (string) XSPEED_EDGE_PROVIDER ) ) { | |
| 348 | + $xspeed_edge_headers = array(); | |
| 349 | + } | |
| 350 | + | |
| 351 | + if ( is_array( $xspeed_edge_headers ) ) { | |
| 352 | + foreach ( $xspeed_edge_headers as $xspeed_edge_name => $xspeed_edge_value ) { | |
| 353 | + header( $xspeed_edge_name . ': ' . $xspeed_edge_value ); | |
| 354 | + } | |
| 355 | + } | |
| 322 | 356 | |
| 323 | 357 | // Record the HIT for the dashboard hit-ratio. The drop-in runs |
| 324 | 358 | // BEFORE WordPress loads, so it can't call Hit_Counter — instead |
| 325 | 359 | // it appends one line to the same hits.log the nginx static path |