Varnish remove from hash_data

261 views Asked by At

Is it possible to remove an item from the hash which has already been added via a previous hash_data() call?

I have a varnish 3 server running in front of a standard LAMP stack and using the Maxmind geoip VMOD per the varnish documentation except there is one included VCL file that I don't have permission to edit which basically has:

sub vcl_hash {
  if (req.http.X-Geo-Country) {
    hash_data(req.http.X-Geo-Country);
  }
}

I know I can call vcl_hash multiple times and they concatenate in order so what I'd like to do is something like the below (un_hash_data doesn't exist) so that only the homepage hashes based on req.http.X-Geo-Country. Is there something like un_hash_data() which can remove this from the hash.

sub vcl_hash {
  if (req.url == "/") {
    un_hash_data(req.http.X-Geo-Country);
  }
}
1

There are 1 answers

0
matheuzzy On

In vcl_recv you can unset req.http.X-Geo-Country for the pages/requests that don't match homepage. If X-Geo-Country is not set/empty - will make the same hash :)