Caching images only

Stefan Caunter stef at
Mon Nov 4 14:15:46 CET 2013

On Mon, Nov 4, 2013 at 7:23 AM, Γιάννης Καραγιαννίδης
<gkaragiannidis at> wrote:
> Hi,
> You could always use
> // remove cookie from these
> if (req.http.Content-Type ~ "(image|audio|video|pdf|flash|text)") { remove req.http.Cookie; }
> Regards
> I am trying to cache all images for my website and it's working fine with simple configuration as given below.
> sub vcl_recv {
>   if (req.url ~ "\.(png|gif|jpg|jpeg|bmp)$"){
>         remove req.http.Cookie;
>    }
> It's caching image url which is simply ending with filename.jpeg, but this can't cache if the url is bit complex like this
> Any idea on how to achieve this. I tried using reqex to match url but failed :(

the regex does not match; you have told varnish to cache files ending
in .jpeg but this test url will fail so you will still have the cookie

without knowing how to reverse engineer your webapp (which is what i
have found you need to do to use varnish usually), it seems to me you
would want to match on the string
"_propertyslider_WAR_propertysliderportlet_img-name" as well as strip
cookies, and set your cache behaviour in fetch


More information about the varnish-misc mailing list