From: Gabriel Wicke Date: Tue, 3 Feb 2004 13:14:10 +0000 (+0000) Subject: added wgSquidMaxage global to configure the Squid cache timeout value from the config X-Git-Tag: 1.3.0beta1~1027 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=a5d23772e2cb02b0db6bea97009ef29bb744a26d;p=lhc%2Fweb%2Fwiklou.git added wgSquidMaxage global to configure the Squid cache timeout value from the config --- diff --git a/LocalSettings.sample b/LocalSettings.sample index 6bda7fd259..8c4de9dfe4 100644 --- a/LocalSettings.sample +++ b/LocalSettings.sample @@ -137,6 +137,10 @@ $wgOutputEncoding = "ISO-8859-1"; # $wgUseESI = true; # Internal server name as known to Squid, if different # $wgInternalServer = 'http://yourinternal.tld:8000'; +# Cache timeout for the squid, will be sent as s-maxage (without ESI) or +# Surrogate-Control (with ESI). Without ESI, you should strip out s-maxage in the Squid config. +# 18000 seconds = 12 hours, more cache hits with 2678400 = 31 days +# $wgSquidMaxage = 18000; # A list of proxy servers (ips if possible) to purge on changes # don't specify ports here (80 is default) # $wgSquidServers = array('127.0.0.1'); diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index dce816f561..5c3eac7af4 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -149,6 +149,10 @@ $wgCookieExpiration = 2592000; # Internal server name as known to Squid, if different # $wgInternalServer = 'http://yourinternal.tld:8000'; $wgInternalServer = $wgServer; +# Cache timeout for the squid, will be sent as s-maxage (without ESI) or +# Surrogate-Control (with ESI). Without ESI, you should strip out s-maxage in the Squid config. +# 18000 seconds = 12 hours, more cache hits with 2678400 = 31 days + $wgSquidMaxage = 18000; # A list of proxy servers (ips if possible) to purge on changes # don't specify ports here (80 is default) # $wgSquidServers = array('127.0.0.1'); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index fc30087605..78cca90da9 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -247,7 +247,7 @@ class OutputPage { } function sendCacheControl() { - global $wgUseSquid, $wgUseESI; + global $wgUseSquid, $wgUseESI, $wgSquidMaxage; # FIXME: This header may cause trouble with some versions of Internet Explorer header( "Vary: Accept-Encoding, Cookie" ); if( $this->mLastModified != "" ) { @@ -259,17 +259,17 @@ class OutputPage { 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( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$wgSquidMaxage.', 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 + # IMPORTANT! The Squid needs 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" ); + header( "Cache-Control: s-maxage='.$wgSquidMaxage.', must-revalidate, max-age=0" ); } } else { # We do want clients to cache if they can, but they *must* check for updates