Varnish only cache assets from single session

cachemagentoreverse-proxyvarnish

Currently I manage to configure varnish to cache items from 1 user, but the when the second users comes in varnish fetch another asset from Apache.

How can I cache static assets behind magento ( css, js , image pdf etc ) accessible from multiple users ?

On vcl_recv, I've configured :

   if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
        unset req.http.Https;
        unset req.http.Cookie;
        return (lookup);
    }

On vcl_fetch :

if (beresp.status == 200 || beresp.status == 301 || beresp.status == 404) {
if (beresp.http.Content-Type ~ "text/html" || beresp.http.Content-Type ~ "text/xml") 
{
    # do something
} else {
    unset beresp.http.expires;
    unset beresp.http.set-cookie;
    set beresp.ttl = 300h;
}

I suspect this this has something to do vcl_hash that store the cache with some kind of client's fingerprint.

Is there a way to manipulate the way it hash only for certain asset types ?

EDIT 1:
Full config : http://pastebin.com/mzSVpEqN

Best Answer

As noted in the comments, comment out the vcl_hash function (provided you don't need it for anything else) and hopefully you should see improvements.

HTH!

Related Topic