r73678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73677‎ | r73678 | r73679 >
Date:20:01, 24 September 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
Support ESI in the resource loader. Only used for the startup module for now, we'll have to think our ESI strategy through before expanding on that
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2280,8 +2280,9 @@
22812281 return $ret;
22822282 }
22832283
2284 - static function makeResourceLoaderLink( $skin, $modules, $only ) {
2285 - global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug;
 2284+ // TODO: Document
 2285+ static function makeResourceLoaderLink( $skin, $modules, $only, $useESI = false ) {
 2286+ global $wgUser, $wgLang, $wgRequest, $wgLoadScript, $wgResourceLoaderDebug, $wgResourceLoaderUseESI;
22862287 // TODO: Should this be a static function of ResourceLoader instead?
22872288 // TODO: Divide off modules starting with "user", and add the user parameter to them
22882289 $query = array(
@@ -2327,11 +2328,22 @@
23282329 }
23292330 // Make queries uniform in order
23302331 ksort( $query );
2331 - // Automatically select style/script elements
2332 - if ( $only === 'styles' ) {
2333 - $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2332+
 2333+ $url = wfAppendQuery( $wgLoadScript, $query );
 2334+ if ( $useESI && $wgResourceLoaderUseESI ) {
 2335+ $esi = Xml::element( 'esi:include', array( 'src' => $url ) );
 2336+ if ( $only == 'styles' ) {
 2337+ $links .= Html::inlineStyle( $esi );
 2338+ } else {
 2339+ $links .= Html::inlineScript( $esi );
 2340+ }
23342341 } else {
2335 - $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2342+ // Automatically select style/script elements
 2343+ if ( $only === 'styles' ) {
 2344+ $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2345+ } else {
 2346+ $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2347+ }
23362348 }
23372349 }
23382350 return $links;
@@ -2348,8 +2360,8 @@
23492361 function getHeadScripts( Skin $sk ) {
23502362 global $wgUser, $wgRequest, $wgUseSiteJs, $wgResourceLoaderDebug;
23512363
2352 - // Statup - this will immediately load jquery and mediawiki modules
2353 - $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts' );
 2364+ // Startup - this will immediately load jquery and mediawiki modules
 2365+ $scripts = self::makeResourceLoaderLink( $sk, 'startup', 'scripts', true );
23542366
23552367 // Configuration -- This could be merged together with the load and go, but makeGlobalVariablesScript returns a
23562368 // whole script tag -- grumble grumble...
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1667,6 +1667,13 @@
16681668 $wgResourceLoaderDebug = false;
16691669
16701670 /**
 1671+ * Enable embedding of certain resources using Edge Side Includes. This will
 1672+ * improve performance but only works if there is something in front of the
 1673+ * web server (e..g a Squid or Varnish server) configured to process the ESI.
 1674+ */
 1675+$wgResourceLoaderUseESI = false;
 1676+
 1677+/**
16711678 * Enable data URL embedding (experimental). This variable is very temporary and
16721679 * will be removed once we get this feature stable.
16731680 */

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:13, 24 September 2010

How are you testing this? I would like to be able to verify it's working.

#Comment by Catrope (talk | contribs)   12:10, 25 September 2010

I'm just verifying the ESI tags show up. I haven't actually installed Squid or Varnish to verify it really works.

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:40, 27 September 2010

Well, the tags appear to be showing up, but only for scripts. What about styles? See OutputPage::getHeadLinks for more resource loader URL building action.

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:42, 27 September 2010

Nevermind my last comment - it's irrelevant

Status & tagging log