Dr0ptp4kt has uploaded a new change for review. https://gerrit.wikimedia.org/r/198805
Change subject: Do not fragment cache with provenance parameter ...................................................................... Do not fragment cache with provenance parameter See also: * I73198f4f294ee36e093dd135e2c38ac604559bb3 * https://lists.wikimedia.org/pipermail/analytics/2015-February/003426.html Change-Id: I23c17a93d2e58df0c2fbcf5cd08e4f6481198975 --- M templates/varnish/mobile-frontend.inc.vcl.erb A templates/varnish/provenance.inc.vcl.erb M templates/varnish/text-frontend.inc.vcl.erb 3 files changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/05/198805/1 diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb b/templates/varnish/mobile-frontend.inc.vcl.erb index ddb8c45..b3266af 100644 --- a/templates/varnish/mobile-frontend.inc.vcl.erb +++ b/templates/varnish/mobile-frontend.inc.vcl.erb @@ -2,6 +2,7 @@ include "errorpage.inc.vcl"; include "zero.inc.vcl"; +include "provenance.inc.vcl"; include "via.inc.vcl"; // Note that via.inc.vcl will set an X-Analytics value of proxy=IORG diff --git a/templates/varnish/provenance.inc.vcl.erb b/templates/varnish/provenance.inc.vcl.erb new file mode 100644 index 0000000..4d90354 --- /dev/null +++ b/templates/varnish/provenance.inc.vcl.erb @@ -0,0 +1,24 @@ +sub vcl_recv { + // Avoid cache fragmentation for well-formed provenance parameters + // Refer to discussion starting from + // https://lists.wikimedia.org/pipermail/analytics/2015-February/003426.html + // Look for wprov parameter with a value + if (req.url ~ "(?i)(\?|&)wprov=([^&]+)") { + // ready a variable for later X-Analytics tagging in vcl_deliver + set req.http.X-WMF-WPROV = regsub(req.url, "(?i)(\?|&)wprov=([^&]+)", "\2"); + // Pretend that the parameter wasn't there for caching purposes + set req.url = regsub(req.url, "(?i)(\?|&)wprov=([^&]+)?$", ""); + set req.url = regsub(req.url, "(?i)(\?|&)wprov=([^&]+)?&", "\1"); + } +} + +sub vcl_deliver { + // In case there was a provenance parameter with a value, add it to X-Analytics + if (req.http.X-WMF-WPROV) { + if (resp.http.X-Analytics) { + set resp.http.X-Analytics = resp.http.X-Analytics + ";wprov=" + req.http.X-WMF-WPROV; + } else { + set resp.http.X-Analytics = "wprov=" + req.http.X-WMF-WPROV; + } + } +} diff --git a/templates/varnish/text-frontend.inc.vcl.erb b/templates/varnish/text-frontend.inc.vcl.erb index ae7fcc6..63afd11 100644 --- a/templates/varnish/text-frontend.inc.vcl.erb +++ b/templates/varnish/text-frontend.inc.vcl.erb @@ -2,6 +2,7 @@ include "errorpage.inc.vcl"; include "text-common.inc.vcl"; +include "provenance.inc.vcl"; include "via.inc.vcl"; // Note that via.inc.vcl will set an X-Analytics value of proxy=IORG -- To view, visit https://gerrit.wikimedia.org/r/198805 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I23c17a93d2e58df0c2fbcf5cd08e4f6481198975 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dr0ptp4kt <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
