Caching only images, no cookies
David Murphy
david at firechaser.com
Wed Feb 2 09:55:26 CET 2011
Hello
I would like to use Varnish to only cache images and to strictly never
cache any cookies. Previous attempts at writing the .vcl file led to
situations where if an image was missing from the server, the
underlying CMS would try to generate a new images (using Imagecache)
and this led to session swapping because cookies were cached and the
passed onto other users.
So, I'm looking to have a very simply, reliable script that only cares
about images and cannot in any circumstances cache cookies.
Would something like this do the trick?
sub vcl_recv {
if (req.url ~ "\.(png|gif|jpg)$") {
lookup;
}
}
# strip the cookie before insertion
sub vcl_fetch {
if (req.url ~ "\.(png|gif|jpg)$") {
unset beresp.http.set-cookie;
}
Thanks, David
More information about the varnish-misc
mailing list