Faidon Liambotis has uploaded a new change for review.

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


Change subject: varnish mobile: don't override MW's X-Analytics
......................................................................

varnish mobile: don't override MW's X-Analytics

Commit I6ac2dd altered the config to override previously set & cached
X-Analytics. This unfortunately included X-Analytics as set by
MediaWiki, which was flagged by the commit message but considered to be
okay at the time.

Turns out it wasn't, so let's be a bit more smart about it and only
unset the previously set X-Analytics only when the request isn't varied
by X-CS. This should have the same effect but without its downsides.

Bug: 54779
Change-Id: Iaf6a7255a5dffd32e43233b19fbeffd60de50cc4
---
M templates/varnish/mobile-frontend.inc.vcl.erb
1 file changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/46/86846/1

diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb 
b/templates/varnish/mobile-frontend.inc.vcl.erb
index a9dc07f..a0eb786 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -131,18 +131,22 @@
 }
 
 sub vcl_deliver {
-       # remove X-CS & X-Analytics from resp if they happen to have it.  We
-       # used to incorrectly set them in vcl_fetch(), which means that our
+       unset resp.http.X-CS;
+
+       # We used to incorrectly set them in vcl_fetch(), which means that our
        # cache is now poisoned with non-varied cached objects that have this
        # incorrectly set with random carriers. Clean up after ourselves.
-       unset resp.http.X-CS;
-       if (req.http.X-Analytics) {
-               # FIXME: replace with std.log()
-               set resp.http.X-Analytics = req.http.X-Analytics;
-       } else {
+       if (resp.http.Vary !~ "X-CS" && resp.http.X-Analytics ~ "zero=") {
+               # no Vary: X-CS and zero in X-Analytics is an invalid 
combination
                unset resp.http.X-Analytics;
        }
 
+       if (resp.http.X-Analytics) {
+               # do nothing, MediaWiki has handled X-Analytics
+       } else if (req.http.X-Analytics) {
+               set resp.http.X-Analytics = req.http.X-Analytics;
+       }
+
        if (resp.http.Cache-Control ~ "s-maxage=[1-9]") {
                set resp.http.Cache-Control = "s-maxage=300, must-revalidate, 
max-age=0";
        } else {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf6a7255a5dffd32e43233b19fbeffd60de50cc4
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <fai...@wikimedia.org>

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

Reply via email to