[Varnish] #465: regsub seems no use in sub_recv as a hash key
Varnish
varnish-bugs at projects.linpro.no
Tue Mar 10 09:24:32 CET 2009
#465: regsub seems no use in sub_recv as a hash key
--------------------------+-------------------------------------------------
Reporter: flyincat | Type: defect
Status: new | Priority: normal
Milestone: | Component: build
Version: 2.0 | Severity: normal
Keywords: hash req.url |
--------------------------+-------------------------------------------------
I'm using varnish 2.0.2 right now. But I encountered a problem with the
varnish cache hash. I reset req.url by
{{{
if (req.url ~ ".(jpg|gif|png)\?.*") {
set req.url = regsub(req.url, "\?.*", "");
}
}}}
cause my urls are all followed with a parameter, and I want to cache the
pictures. however, when I visited a same url with a different parameter,
varnish told me it's missed and fetch content from the backend server.
(For example, I first visit a url:
http://www.example.com/h/Mzatest.jpg?m=0301, then I change the parameter
0301 to 0302 and retrieve again.It will told me it's missed)
I solved this problem by reset hash key in sub_hash:
{{{
sub vcl_hash {
if (req.url ~ ".(jpg|gif|png)\?.*") {
set req.hash += regsub(req.url, "\?.*", "");
}
else {
set req.hash += req.url;
}
hash;
}}}
It works!
--
Ticket URL: <http://varnish.projects.linpro.no/ticket/465>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list