<font size="2"><font face="georgia,serif">Or not set a header at all:</font></font><div><font size="2"><font face="georgia,serif"><br></font></font></div><div><font size="2" face="'courier new', monospace">if ( req.url ~ "^[^\?]*?\.(js|gif|jpg|jpeg|png|ico|css|html|ehtml|shtml|swf)($|\?)" ) {</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace"><font size="2">    </font>unset req.http.cookie</font></div><div><font class="Apple-style-span" face="'courier new', monospace">    return(lookup);</font></div>

<meta charset="utf-8"><div><font size="2" face="'courier new', monospace">}</font></div><div><font size="2"><font face="georgia,serif"><br></font></font></div><div><font size="2"><font face="georgia,serif">Didn't test the regex with Varnish's regex handling.<br clear="all">

</font></font><font face="georgia, serif">-- </font><div><font face="georgia, serif">kb</font></div><br>
<br><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 12:30, AD <span dir="ltr"><<a href="mailto:straightflush@gmail.com">straightflush@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

You can remove the header so it doesnt get set<div class="im"><div><br></div><div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">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)$" ) {</span></div></div><div><span style="border-collapse:collapse;font-family:arial, sans-serif;font-size:13px">     <b><i> remove req.http.ext; </i></b><br>


      return(lookup);<br>    }</span></div><div><div></div><div class="h5"><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br></span></font></div><div><font face="arial, sans-serif"><span style="border-collapse:collapse"><br>


</span></font><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 2:59 PM, Per Buer <span dir="ltr"><<a href="mailto:perbu@varnish-software.com" target="_blank">perbu@varnish-software.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi David, List.<br>
<br>
I think I'll use this snipplet in the documentation if you don't mind.<br>
I need to work in more regsub calls there anyway.<br>
<br>
Cheers,<br>
<br>
Per.<br>
<div><div></div><div><br>
On Wed, Mar 16, 2011 at 7:51 PM, David Helkowski <<a href="mailto:dhelkowski@sbgnet.com" target="_blank">dhelkowski@sbgnet.com</a>> wrote:<br>
> The vcl you are showing may be standard, but as you have noticed it will not<br>
> work properly when<br>
> query strings end in a file extension. I encountered this same problem after<br>
> blindly copying from<br>
> example varnish configurations.<br>
> Before the check is done, the query parameter needs to be stripped from the<br>
> 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 ~<br>
> "^(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.<br>
> I use it in a production<br>
> environment and it works fine though. Pass it along to your hosting provider<br>
> 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<br>
> with the file extension.<br>
> You can add a 'remove req.http.ext' after the code if you don't want that to<br>
> happen...<br>
><br>
> Another thing to consider is that whether it this is a bug or not; it is a<br>
> common problem with varnish<br>
> configurations, and as such can be used on most varnish servers to force<br>
> them to return things<br>
> differently then they normally would. IE: if some backend script is a huge<br>
> request and eats up resources, sending<br>
> it a '?.jpg' could be used to hit it repeatedly and bring about a denial of<br>
> service.<br>
><br>
> On 3/16/2011 11:55 AM, Chris Bloom wrote:<br>
><br>
> Thank you, Bjorn, for your response.<br>
> Our hosting provider tells me that the following routines have been added to<br>
> the default config.<br>
> sub vcl_recv {<br>
>   # Cache things with these extensions<br>
>   if (req.url ~<br>
> "\.(js|css|JPG|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$") {<br>
>     unset req.http.cookie;<br>
>     return (lookup);<br>
>   }<br>
> }<br>
> sub vcl_fetch {<br>
>   # Cache things with these extensions<br>
>   if (req.url ~<br>
> "\.(js|css|JPG|jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf)$") {<br>
>     unset req.http.set-cookie;<br>
>     set obj.ttl = 1h;<br>
>   }<br>
> }<br>
> Clearly the req.url variable contains the entire request URL, including the<br>
> querystring. Is there another variable that I should be using instead that<br>
> would only include the script name? If this is the default behavior, I'm<br>
> inclined to cry "bug".<br>
> You can test that other script for yourself by substituting<br>
> <a href="http://maxisavergroup.com" target="_blank">maxisavergroup.com</a> for the domain in the example URLs I provided.<br>
> PS: We are using Varnish 2.0.6<br>
><br>
> _______________________________________________<br>
> varnish-misc mailing list<br>
> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
> <a href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>
><br>
> _______________________________________________<br>
> varnish-misc mailing list<br>
> <a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
> <a href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Per Buer, Varnish Software<br>
Phone: <a href="tel:%2B47%2021%2098%2092%2061" target="_blank">+47 21 98 92 61</a> / Mobile: <a href="tel:%2B47%20958%2039%20117" target="_blank">+47 958 39 117</a> / Skype: per.buer<br>
Varnish makes websites fly!<br>
Want to learn more about Varnish? <a href="http://www.varnish-software.com/whitepapers" target="_blank">http://www.varnish-software.com/whitepapers</a><br>
</font><div><div></div><div><br>
_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
<a href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a href="http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" target="_blank">http://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br></blockquote></div><br></div>