• Poul-Henning Kamp's avatar
    Implement runtime part of VCL controlled hashing. · c12e7eb7
    Poul-Henning Kamp authored
    The vcl_hash() is now used to control which fields go
    into the hash algorithm, and the default is stil,
    as previously, the URL + Host: header.
    
    But now it is controlled by the vcl code, with the
    default vcl_hash() being:
    
    	sub vcl_hash {
    		req.hash += req.url;
    		req.hash += req.http.host;
    		hash;
    	}
    
    Once I get a bit further, this will be changed to
    
    	sub vcl_hash {
    		req.hash += req.url;
    		if (req.http.host) {
    			req.hash += req.http.host;
    		} else {
    			req.hash += server.ip;
    		}
    		hash;
    	}
    
    So that we correctly hash HTTP requests without Host:
    headers, that go to a machine with multiple IP numbers.
    
    If you want to add fields to the hash, just write
    a vcl_hash that does not end in "hash;":
    
    	sub vcl_hash {
    		req.hash += req.http.cookie;
    	}
    
    If you want to override the default vcl_hash, just
    say so:
    
    	sub vcl_hash {
    		req.hash += req.url;
    		hash;	// do not continue into default vcl_hash
    	}
    
    
    
    
    git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1398 d4fa192b-c00b-0410-8231-f00ffab90ce4
    c12e7eb7
cache_vrt.c 7.18 KB