Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -399,6 +399,7 @@ |
400 | 400 | } |
401 | 401 | |
402 | 402 | protected function sendCacheHeaders() { |
| 403 | + global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI; |
403 | 404 | $response = $this->getRequest()->response(); |
404 | 405 | |
405 | 406 | if ( $this->mCacheMode == 'private' ) { |
— | — | @@ -407,9 +408,12 @@ |
408 | 409 | } |
409 | 410 | |
410 | 411 | if ( $this->mCacheMode == 'anon-public-user-private' ) { |
411 | | - global $wgUseXVO, $wgOut; |
412 | | - $response->header( 'Vary: Accept-Encoding, Cookie' ); |
| 412 | + $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : ''; |
| 413 | + $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp ); |
413 | 414 | if ( $wgUseXVO ) { |
| 415 | + if ( $wgVaryOnXFPForAPI ) { |
| 416 | + $wgOut->addVaryHeader( 'X-Forwarded-Proto' ); |
| 417 | + } |
414 | 418 | $response->header( $wgOut->getXVO() ); |
415 | 419 | if ( $wgOut->haveCacheVaryCookies() ) { |
416 | 420 | // Logged in, mark this request private |
— | — | @@ -424,6 +428,15 @@ |
425 | 429 | return; |
426 | 430 | } // else no XVO and anonymous, send public headers below |
427 | 431 | } |
| 432 | + |
| 433 | + // Send public headers |
| 434 | + if ( $wgVaryOnXFPForAPI ) { |
| 435 | + $response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' ); |
| 436 | + if ( $wgUseXVO ) { |
| 437 | + // Bleeeeegh. Our header setting system sucks |
| 438 | + $response->header( 'X-Vary-Options: Accept-Encoding;list-contains=gzip, X-Forwarded-Proto' ); |
| 439 | + } |
| 440 | + } |
428 | 441 | |
429 | 442 | // If nobody called setCacheMaxAge(), use the (s)maxage parameters |
430 | 443 | if ( !isset( $this->mCacheControl['s-maxage'] ) ) { |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1739,6 +1739,13 @@ |
1740 | 1740 | /** Send X-Vary-Options header for better caching (requires patched Squid) */ |
1741 | 1741 | $wgUseXVO = false; |
1742 | 1742 | |
| 1743 | +/** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API |
| 1744 | + * requests. Use this if you have an SSL termination setup and want to split |
| 1745 | + * the cache between HTTP and HTTPS for API requests. This does not affect |
| 1746 | + * 'regular' requests. |
| 1747 | + */ |
| 1748 | +$wgVaryOnXFPForAPI = false; |
| 1749 | + |
1743 | 1750 | /** |
1744 | 1751 | * Internal server name as known to Squid, if different. Example: |
1745 | 1752 | * <code> |