puzzle about unset req.http.cookie

Mattias Geniar mattias at nucleus.be
Mon Jun 20 10:58:06 CEST 2011

> if(req.url ‾ ".(js|css|jpg|png|gif|swf|jpeg|ico)$){
> unset req.http.cookie;
> }
> it says if images have cookie,It can not be cached.

Actually, that's not what it says. You're saying if the requested file ends in .js, .css, .jpg, ... or any of those file types, you will unset any cookie that is being sent along and force it to be cached.

If you want to say "if the image has a cookie, don't cache it" you can do a check if a cookie exists on your request and just pass it on to your backend, something like this:
if (req.http.cookie) {
	return (pass);

Mattias Geniar

More information about the varnish-dev mailing list