req.hash using req.url without query string ?

Laurence Rowe l at
Thu Apr 21 13:36:11 CEST 2011

On 21 April 2011 11:17, cosmih <cosmih at> wrote:
> Hi,
> By default the cache key is made using and req.url and this
> means that for the same resource requested with a different query string we
> have a different cache key, object.
> However I need that for few specific URLs (static content) to have only one
> cache object per URL and serve it no matter what query string I have.
> Something like in the below example:
> Lets suppose that I have the following URLs:
> :
> :
> I want to use only
> /a_specific_path/image.png   +
> for creating/checking  the cache key and to serve this cache object no
> matter what query string "parameterN=valueN" I have to this specific URL.
> It is possible ?
> Thanks,

You can normalize the url on the way in, something like this should do
the trick:

sub vcl_recv {
    set req.url = regsub(req.url, "\?.*$", "");


More information about the varnish-misc mailing list