From: Gabriel Wicke Date: Sat, 31 Jan 2004 12:45:09 +0000 (+0000) Subject: Initial support for Squid3 and ESI. Adds $wgUseESI and sends Surrogate-Control Header... X-Git-Tag: 1.3.0beta1~1050 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=84679b35fba8ad8d39f1f3e7701b35d1367fba33;p=lhc%2Fweb%2Fwiklou.git Initial support for Squid3 and ESI. Adds $wgUseESI and sends Surrogate-Control Header if enabled. No Cache-Control header stripping required on the Squid. --- diff --git a/LocalSettings.sample b/LocalSettings.sample index 96dd1742cf..6bda7fd259 100644 --- a/LocalSettings.sample +++ b/LocalSettings.sample @@ -133,6 +133,8 @@ $wgOutputEncoding = "ISO-8859-1"; # # Enable/disable Squid # $wgUseSquid = true; +# If you run Squid3 with ESI support, enable this (default:false): +# $wgUseESI = true; # Internal server name as known to Squid, if different # $wgInternalServer = 'http://yourinternal.tld:8000'; # A list of proxy servers (ips if possible) to purge on changes diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index daffa99879..cce591b7e2 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -142,6 +142,8 @@ $wgCookieExpiration = 2592000; # # Enable/disable Squid $wgUseSquid = false; +# If you run Squid3 with ESI support, enable this (default:false): + $wgUseESI = false; # Internal server name as known to Squid, if different # $wgInternalServer = 'http://yourinternal.tld:8000'; $wgInternalServer = $wgServer; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 4a5376a91a..1743f25e64 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -248,15 +248,30 @@ class OutputPage { } function sendCacheControl() { - global $wgUseSquid; + global $wgUseSquid, $wgUseESI; # FIXME: This header may cause trouble with some versions of Internet Explorer header( "Vary: Accept-Encoding, Cookie" ); if( $this->mLastModified != "" ) { if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) ) { - # We'll purge the proxy cache for anons explicitly, but require end user agents - # to revalidate against the proxy on each visit. - wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false ); - header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" ); + if ( $wgUseESI ) { + # We'll purge the proxy cache for anons explicitly, but require end user agents + # to revalidate against the proxy on each visit. + # Surrogate-Control controls our Squid, Cache-Control downstream caches + wfDebug( "** proxy caching with ESI; {$this->mLastModified} **\n", false ); + # start with a shorter timeout for initial testing + # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"'); + header( 'Surrogate-Control: max-age=18000+18000, content="ESI/1.0"'); + header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' ); + } else { + # We'll purge the proxy cache for anons explicitly, but require end user agents + # to revalidate against the proxy on each visit. + # The Squid need to replace the Cache-Control header with + # Cache-Control: s-maxage=0, must-revalidate, max-age=0 + wfDebug( "** local proxy caching; {$this->mLastModified} **\n", false ); + # start with a shorter timeout for initial testing + # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" ); + header( "Cache-Control: s-maxage=18000, must-revalidate, max-age=0" ); + } } else { # We do want clients to cache if they can, but they *must* check for updates # on revisiting the page.