Mark Bergsma has uploaded a new change for review.

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


Change subject: Mobile Cookie Vary caching optimizations
......................................................................

Mobile Cookie Vary caching optimizations

Change-Id: Iad3000fb619e25930a94bb35f3ca96862c9fbf89
---
M templates/varnish/mobile-backend.inc.vcl.erb
M templates/varnish/mobile-frontend.inc.vcl.erb
2 files changed, 14 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/16/75316/1

diff --git a/templates/varnish/mobile-backend.inc.vcl.erb 
b/templates/varnish/mobile-backend.inc.vcl.erb
index 70992b0..5328033 100644
--- a/templates/varnish/mobile-backend.inc.vcl.erb
+++ b/templates/varnish/mobile-backend.inc.vcl.erb
@@ -31,10 +31,6 @@
                /* We only deal with GET and HEAD by default */
                return (pass);
        }
-       if (req.http.Authorization || req.http.Cookie) {
-               /* Not cacheable by default */
-               return (pass);
-       }
        return (lookup);
 }
 
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb 
b/templates/varnish/mobile-frontend.inc.vcl.erb
index d43d215..cba7b28 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -47,19 +47,6 @@
         * do this after vcl_recv_purge, as it operates on a full URI */
        call rewrite_proxy_urls;
 
-       /* FIXME: deploy X-Vary-Options support */
-       set req.http.X-Orig-Cookie = req.http.Cookie;
-       if( req.http.Cookie ~ "disable" ||
-               req.http.Cookie ~ "optin" ||
-               req.http.Cookie ~ "session" ||
-               req.http.Cookie ~ "forceHTTPS" ) {
-               /* Do nothing; these are the cookies we pass.
-                * this is a hack in the absence of X-V-O support
-                */
-       } else {
-               unset req.http.Cookie;
-       }
-
        if (req.http.host == "m.wikipedia.org") {
                if (req.http.X-CS) {
                        // Carrier detected
@@ -81,6 +68,20 @@
 
        call device_detection;
 
+       if (req.http.Cookie ~ "([sS]ession|Token)=") {
+               return (pass);
+       }
+       
+       set req.http.X-Orig-Cookie = req.http.Cookie;
+       set req.http.Cookie = regsuball(req.http.X-Orig-Cookie, 
"^.*([a-zA-Z]+wikidisableImages=1|optin=1|[a-zA-Z]+wikiforceHTTPS=true).*$", 
"\1; ");
+       set req.http.Cookie = regsub(req.http.Cookie, "; $", "");
+
+       /* Users that just logged out, should not get a 304 for their
+        * (locally cached) logged in pages. */
+       if (req.http.If-Modified-Since && req.http.X-Orig-Cookie ~ "LoggedOut") 
{
+               unset req.http.If-Modified-Since;
+       }
+
        if ( req.http.host ~ "^test\." ) {
                return (pass);
        }
@@ -98,10 +99,6 @@
        }
        if (req.request != "GET" && req.request != "HEAD") {
                /* We only deal with GET and HEAD by default */
-               return (pass);
-       }
-       if (req.http.Authorization || req.http.Cookie) {
-               /* Not cacheable by default */
                return (pass);
        }
        return (lookup);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad3000fb619e25930a94bb35f3ca96862c9fbf89
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <m...@wikimedia.org>

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

Reply via email to