Cookie inspection

Omar Kilani omar.kilani at gmail.com
Tue May 29 07:05:08 CEST 2007


Hi there,

I have a web application which supports a bunch of interface/website
languages via Accept-Language headers and/or a user-overridden cookie
value.

I'd like to modify req.hash in vcl_hash to take into account the value
of this particular cookie (similar to what Denis does with
Accept-Encoding here:
http://projects.linpro.no/pipermail/varnish-misc/2007-May/000407.html
-- neat! :)

>From looking through the varnish-cache code, I don't think this type
of operation is supported, and I'm not sure what the best way to
represent this in VCL is.

Including the entire req.http.Cookie in the hash key is suboptimal as
there are a bunch of other cookies set (session cookies, etc)
depending on other variables.

Doing something like req.http.Cookie.LANGUAGE *could* theoretically do
the right thing (and use http_GetHdrField, although some browsers can
send multiple values for the same cookie name... :) and *looks* right,
but obviously has a very different meaning in VCL where it compiles
to:

VRT_GetHdr(sp, 1, "\020Cookie.LANGUAGE:")

I've created a small patch:

http://treehou.se/~omar/cookie-inspection-1.patch

Which implements VRT_GetHdrField and cookie inspection.

This should be a lot more general, but is this something that varnish
could potentially support?

The other thing I'd like to be able to do is have some sort of 'first
match over an array of header values' VCL construct, so you could vary
the hash by whatever languages in Accept-Language your site supports
-- but the cookie thing would be workable too.

Thanks!

Regards,
Omar



More information about the varnish-misc mailing list