r94590 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94589‎ | r94590 | r94591 >
Date:23:32, 15 August 2011
Author:preilly
Status:deferred (Comments)
Tags:mobile 
Comment:
add vary support for x-device to allow proper purging of varnish cache
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -49,7 +49,7 @@
5050 $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' );
5151
5252 class ExtMobileFrontend {
53 - const VERSION = '0.5.25';
 53+ const VERSION = '0.5.26';
5454
5555 /**
5656 * @var DOMDocument
@@ -341,6 +341,7 @@
342342 $mAction !== 'view_normal_site' ) {
343343 $this->getMsg();
344344 $this->disableCaching();
 345+ $this->sendXDeviceVaryHeader();
345346 ob_start( array( $this, 'DOMParse' ) );
346347 }
347348 }
@@ -376,6 +377,15 @@
377378 header( 'Pragma: no-cache' );
378379 }
379380 }
 381+
 382+ private function sendXDeviceVaryHeader() {
 383+ global $wgOut;
 384+
 385+ if ( !empty( $_SERVER['HTTP_X_DEVICE'] ) ) {
 386+ header( 'X-Device: ' . $_SERVER['HTTP_X_DEVICE'] );
 387+ $wgOut->addVaryHeader( 'X-Device' );
 388+ }
 389+ }
380390
381391 private function renderOptInMobileSiteXHTML() {
382392 if ( $this->contentFormat == 'XHTML' ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r94591mft r94590preilly23:33, 15 August 2011

Comments

#Comment by Bawolff (talk | contribs)   04:35, 16 August 2011

btw, empty is discouraged in the coding conventions page.


potential edge case: someone enables this extension slightly before doing the varnish patch thingy that adds the x-device. Then there might get a whole bunch of pages stuck in cache that aren't varying by x-device. I'm not sure if that's an actual issue or not.

Status & tagging log