r80583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80582‎ | r80583 | r80584 >
Date:19:31, 19 January 2011
Author:catrope
Status:ok
Tags:
Comment:
Followup r73686: make private modules really private (i.e. Cache-Control: private instead of s-maxage=0 , for paranoia) and make debug requests really uncacheable (with no-cache, and a Pragma: no-cache for HTTP 1.0 clients)
Modified paths:
  • /trunk/phase3/includes/resourceloader/ResourceLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoader.php
@@ -329,14 +329,15 @@
330330
331331 wfProfileIn( __METHOD__.'-getModifiedTime' );
332332
 333+ $private = false;
333334 // To send Last-Modified and support If-Modified-Since, we need to detect
334335 // the last modified time
335336 $mtime = wfTimestamp( TS_UNIX, $wgCacheEpoch );
336337 foreach ( $modules as $module ) {
337338 try {
338 - // Bypass squid cache if the request includes any private modules
 339+ // Bypass Squid and other shared caches if the request includes any private modules
339340 if ( $module->getGroup() === 'private' ) {
340 - $smaxage = 0;
 341+ $private = true;
341342 }
342343 // Calculate maximum modified time
343344 $mtime = max( $mtime, $module->getModifiedTime( $context ) );
@@ -355,10 +356,18 @@
356357 }
357358 header( 'Last-Modified: ' . wfTimestamp( TS_RFC2822, $mtime ) );
358359 if ( $context->getDebug() ) {
359 - header( 'Cache-Control: must-revalidate' );
 360+ // Do not cache debug responses
 361+ header( 'Cache-Control: private, no-cache, must-revalidate' );
 362+ header( 'Pragma: no-cache' );
360363 } else {
361 - header( "Cache-Control: public, max-age=$maxage, s-maxage=$smaxage" );
362 - header( 'Expires: ' . wfTimestamp( TS_RFC2822, min( $maxage, $smaxage ) + time() ) );
 364+ if ( $private ) {
 365+ header( "Cache-Control: private, max-age=$maxage" );
 366+ $exp = $maxage;
 367+ } else {
 368+ header( "Cache-Control: public, max-age=$maxage, s-maxage=$smaxage" );
 369+ $exp = min( $maxage, $smaxage );
 370+ }
 371+ header( 'Expires: ' . wfTimestamp( TS_RFC2822, $exp + time() ) );
363372 }
364373
365374 // If there's an If-Modified-Since header, respond with a 304 appropriately

Follow-up revisions

RevisionCommit summaryAuthorDate
r810001.17: MFT r80576, r80583, r80656, r80842, r80900, r80913, r80918, r80919, r80...catrope22:49, 25 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73686* Fixed bug #25281 by adding special treatment for modules in the "private" g...tparscal22:10, 24 September 2010

Status & tagging log