Mark Bergsma has uploaded a new change for review.

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


Change subject: Add a function vcl_error_keepalive and use it for PURGES
......................................................................

Add a function vcl_error_keepalive and use it for PURGES

Varnish always closes the HTTP connection when going through vcl_error.
Because we use vcl_error for things like purging, geoip and redirects,
this is suboptimal. We've patched Varnish to support persistent
connections when the object's Connection: response header is set to
"keep-alive", and if the client allows it.

Change-Id: I33ea1753ce37512f7532e090e426a29f351bcd3e
---
M modules/varnish/templates/vcl/wikimedia.vcl.erb
1 file changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/30/72530/1

diff --git a/modules/varnish/templates/vcl/wikimedia.vcl.erb 
b/modules/varnish/templates/vcl/wikimedia.vcl.erb
index 531d6c0..35b3902 100644
--- a/modules/varnish/templates/vcl/wikimedia.vcl.erb
+++ b/modules/varnish/templates/vcl/wikimedia.vcl.erb
@@ -197,6 +197,13 @@
 }
 
 <% end -%>
+sub vcl_error_keepalive {
+       if ((req.proto == "HTTP/1.1" && req.http.Connection != "close")
+               || (req.proto != "HTTP/1.1" && req.http.Connection == 
"keep-alive")) {
+               set obj.http.Connection = "keep-alive";
+       }
+}
+
 sub vcl_recv {
        if (req.request != "GET" && req.request != "HEAD" && req.request != 
"POST" && req.request != "PURGE") {
                /* We only deal with GET, HEAD and POST by default */
@@ -293,7 +300,12 @@
        if (obj.status == 503 && req.restarts < <%= vcl_config["retry503"].to_i 
%>) {
                return(restart);
        }
+
 <% end -%>
+       if (obj.status == 200 && req.request == "PURGE") {
+               call vcl_error_keepalive;
+       }
+
        /* Function vcl_error in <%= vcl %>.inc.vcl will be appended here */
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33ea1753ce37512f7532e090e426a29f351bcd3e
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to