Hash in response + purge.hash for Varnish 2.1

Varnish 2.1 made req.hash unreadable / does not store it. So purge.hash will no longer work.

Getting hash output back

sub vcl_hash{
  set req.http.X-Hash = req.http.host;
  ... more stuff ...
  set req.http.X-Hash = req.http.X-Hash "#"; # add trailing '#' to be compatible to varnish 2.0
  set req.hash += req.http.X-Hash; # store in unreadable req.hash

sub vcl_deliver {
  ... more stuff ...
  # store hash in response for matching / testing that hashing works
  set resp.http.X-Hash = req.http.X-Hash;
  return (deliver);

Purging on hash

varnishadm -T 'purge req.http.X-Hash ~ something'

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s