<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
The vcl you are showing may be standard, but as you have noticed it
will not work properly when<br>
query strings end in a file extension. I encountered this same
problem after blindly copying from<br>
example varnish configurations.<br>
Before the check is done, the query parameter needs to be stripped
from the url.<br>
Example of an alternate way to check the extensions:<br>
<br>
sub vcl_recv {<br>
...<br>
set req.http.ext = regsub( req.url, "\?.+$", "" );<br>
set req.http.ext = regsub( req.http.ext, ".+\.([a-zA-Z]+)$",
"\1" );<br>
if( req.http.ext ~
"^(js|gif|jpg|jpeg|png|ico|css|html|ehtml|shtml|swf)$" ) {<br>
return(lookup);<br>
}<br>
...<br>
}<br>
<br>
Doubtless others will say this approach is wrong for some reason or
another. I use it in a production<br>
environment and it works fine though. Pass it along to your hosting
provider and request that they<br>
consider changing their config.<br>
<br>
Note that the above code will cause the end user to receive a 'ext'
header with the file extension.<br>
You can add a 'remove req.http.ext' after the code if you don't want
that to happen...<br>
<br>
Another thing to consider is that whether it this is a bug or not;
it is a common problem with varnish<br>
configurations, and as such can be used on most varnish servers to
force them to return things<br>
differently then they normally would. IE: if some backend script is
a huge request and eats up resources, sending<br>
it a '?.jpg' could be used to hit it repeatedly and bring about a
denial of service.<br>
<br>
On 3/16/2011 11:55 AM, Chris Bloom wrote:
<blockquote
cite="mid:AANLkTinJFndN4Cn_ZwQTnUTWvaZn-QiB=nv771veo5+Z@mail.gmail.com"
type="cite">Thank you, Bjorn, for your response.
<div><br>
</div>
<div>Our hosting provider tells me that the following routines
have been added to the default config.</div>
<div><br>
</div>
<div>
<div><font class="Apple-style-span" face="'courier new',
monospace">sub vcl_recv {</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> # Cache things with these extensions</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> if (req.url ~
"\.(js|css|JPG|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$")
{</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> unset req.http.cookie;</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> return (lookup);</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> }</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">}</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">sub vcl_fetch {</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> # Cache things with these extensions </font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> if (req.url ~
"\.(js|css|JPG|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$")
{</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> unset req.http.set-cookie;</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> set obj.ttl = 1h;</font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace"> } </font></div>
<div><font class="Apple-style-span" face="'courier new',
monospace">}</font></div>
</div>
<div><br>
</div>
<div>Clearly the req.url variable contains the entire request URL,
including the querystring. Is there another variable that I
should be using instead that would only include the script name?
If this is the default behavior, I'm inclined to cry "bug".</div>
<div><br>
</div>
<div>You can test that other script for yourself by substituting <a
moz-do-not-send="true" href="http://maxisavergroup.com">maxisavergroup.com</a>
for the domain in the example URLs I provided.</div>
<div><br>
</div>
<div>PS: We are using Varnish 2.0.6</div>
<div><br>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
varnish-misc mailing list
<a class="moz-txt-link-abbreviated" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>
<a class="moz-txt-link-freetext" href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a></pre>
</blockquote>
<br>
</body>
</html>