/** Send X-Vary-Options header for better caching (requires patched Squid) */
$wgUseXVO = false;
+/** Add X-Forwarded-Proto to the Vary and X-Vary-Options headers for API
+ * requests. Use this if you have an SSL termination setup and want to split
+ * the cache between HTTP and HTTPS for API requests. This does not affect
+ * 'regular' requests.
+ */
+$wgVaryOnXFPForAPI = false;
+
/**
* Internal server name as known to Squid, if different. Example:
* <code>
}
protected function sendCacheHeaders() {
+ global $wgUseXVO, $wgOut, $wgVaryOnXFPForAPI;
$response = $this->getRequest()->response();
if ( $this->mCacheMode == 'private' ) {
}
if ( $this->mCacheMode == 'anon-public-user-private' ) {
- global $wgUseXVO, $wgOut;
- $response->header( 'Vary: Accept-Encoding, Cookie' );
+ $xfp = $wgVaryOnXFPForAPI ? ', X-Forwarded-Proto' : '';
+ $response->header( 'Vary: Accept-Encoding, Cookie' . $xfp );
if ( $wgUseXVO ) {
+ if ( $wgVaryOnXFPForAPI ) {
+ $wgOut->addVaryHeader( 'X-Forwarded-Proto' );
+ }
$response->header( $wgOut->getXVO() );
if ( $wgOut->haveCacheVaryCookies() ) {
// Logged in, mark this request private
return;
} // else no XVO and anonymous, send public headers below
}
+
+ // Send public headers
+ if ( $wgVaryOnXFPForAPI ) {
+ $response->header( 'Vary: Accept-Encoding, X-Forwarded-Proto' );
+ if ( $wgUseXVO ) {
+ // Bleeeeegh. Our header setting system sucks
+ $response->header( 'X-Vary-Options: Accept-Encoding;list-contains=gzip, X-Forwarded-Proto' );
+ }
+ }
// If nobody called setCacheMaxAge(), use the (s)maxage parameters
if ( !isset( $this->mCacheControl['s-maxage'] ) ) {