CSteipp has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/85036


Change subject: Set Squid maxage so proxies will cache
......................................................................

Set Squid maxage so proxies will cache

Since OutputPage will send Cache-Control: private if s-maxage is 0
(even with mEnableClientCache set, see OutputPage::sendCacheControl())
set a squid maxage for /start and /checkLoggedIn phases.

The proxy *must not* use the cached value if the client is sending
cookies with the request, so Vary headers are also set for the call
to loginwiki (/checkLoggedIn).

Bug: 54195
Change-Id: I45e2167826d91e6132a35c3fab99843f481e1c5a
---
M specials/SpecialCentralAutoLogin.php
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/36/85036/1

diff --git a/specials/SpecialCentralAutoLogin.php 
b/specials/SpecialCentralAutoLogin.php
index 8bd3438..3ab9f3f 100644
--- a/specials/SpecialCentralAutoLogin.php
+++ b/specials/SpecialCentralAutoLogin.php
@@ -112,6 +112,7 @@
                case 'start': // Main entry point
                        // Note this is safe to cache, because the cache 
already varies on
                        // the session cookies.
+                       $this->getOutput()->setSquidMaxage( 1200 );
 
                        if ( !$this->checkIsLocalWiki() ) {
                                return;
@@ -127,6 +128,8 @@
                case 'checkLoggedIn': // Check if we're logged in centrally
                        // Note this is safe to cache, because the cache 
already varies on
                        // the session cookies.
+                       $this->getOutput()->setSquidMaxage( 1200 );
+                       $this->getOutput()->addVaryHeader( 'Cookie', 
$this->getVaryCookieOptions() );
 
                        if ( !$this->checkIsCentralWiki( $wikiid ) ) {
                                return;
@@ -527,4 +530,18 @@
 
                return $centralSession;
        }
+
+       /**
+        * Returns an array of Vary options, sent to OutputPage::addVaryHeader()
+        * @returns array of cookie strings to vary on
+        */
+       private function getVaryCookieOptions() {
+               global $wgCentralAuthCookiePrefix;
+               $cookiesOption = array();
+               $centralauthCookies = array( 'Session', 'Token', 'User' );
+               foreach ( $centralauthCookies as $cookieName ) {
+                       $cookiesOption[] = 'string-contains=' . 
$wgCentralAuthCookiePrefix . $cookieName;
+               }
+               return $cookiesOption;
+       }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/85036
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45e2167826d91e6132a35c3fab99843f481e1c5a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: CSteipp <cste...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to