Created
August 27, 2010 02:56
-
-
Save mardambey/552701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub vcl_hash { | |
set req.hash += req.url; | |
set req.hash += req.http.host; | |
set req.http.X-Calc-Hash = "true"; | |
if( req.http.Cookie ~ "JSESSIONID" ) { | |
set req.http.X-Varnish-Hashed-On = | |
regsub( req.http.Cookie, "^.*?JSESSIONID=([a-zA-z0-9]{32}\.[a-zA-Z0-9]+)([\s$\n])*.*?$", "\1" ); | |
set req.hash += req.http.X-Varnish-Hashed-On; | |
} | |
return(hash); | |
} |
In case somebody stumbles upon this, Varnish has replaced req.hash with hash_data()
https://www.varnish-cache.org/docs/3.0/installation/upgrade.html#req-hash-is-replaced-with-hash-data
So this becomes
sub vcl_hash {
hash_data( req.url );
hash_data( req.http.host);
set req.http.X-Calc-Hash = "true";
if( req.http.Cookie ~ "JSESSIONID" ) {
set req.http.X-Varnish-Hashed-On = regsub( req.http.Cookie, "^.?JSESSIONID=([a-zA-z0-9]{32}.[a-zA-Z0-9]+)([\s$\n]).*?$", "\1" );
hash_data( req.http.X-Varnish-Hashed-On);
} return(hash); }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you explain the PCRE part?