caching using ETags to vary the content
miles at jamkit.com
Tue Nov 4 21:51:49 CET 2008
I am using varnish 2.0-beta-2.
I am using varnish to cache a website where there is a small amount of
personalised content in a particular directory. When the user is
outside of that directory, the only difference for logged-in and
non-logged-in users is a few links (e.g. login/register or view
profile/logout - the targets are the same irrespective of which user).
I am trying to come up with a cache setup to deal with this.
How I had planned to deal with this was as follows:
- set an ETag (e.g. "logged-in" or "anon") depending on whether the
user is logged in or not;
- add a "Vary: ETag" header, so varnish stores several representations
- in varnish, set an "ETag" header on the request when it is received,
depending on if the user is authenticated or not (can be determined by
the presence of a cookie). the request should then match the correct
page in the cache.
I know varnish doesn't do If-None-Match, but I don't think that is a
problem in this scheme.
I haven't attempted this yet - can anyone see any holes in it as a
method? Or does anyone else have a way of dealing with this sort of
Thanks in advance for your help!
More information about the varnish-misc