Dealing with large unwanted objects
Mark Moseley
moseleymark at gmail.com
Thu Nov 4 19:42:44 CET 2010
On Wed, Nov 3, 2010 at 12:30 AM, Tollef Fog Heen
<tfheen at varnish-software.com> wrote:
> ]] Mark Moseley
>
> | I'm doing a half-way job of it by calling 'pass' in vcl_fetch, i.e.,
>
> As Per's pointed out, that won't actually do what you want, which is to
> pipe. However, we can use a neat trick: restart, and the fact that we
> can check headers in vcl_fetch, we haven't grabbed the body yet.
>
> Something like:
>
> sub vcl_recv {
> if (req.http.x-pipe && req.restarts > 0) {
> return(pipe);
> }
> }
>
> sub vcl_fetch {
> # This is the rule to knock out big files
> if ( beresp.http.Content-Length ~ "[0-9]{8,}" ) {
> set req.http.x-pipe = "1";
> restart;
> }
>
> I believe this should work. It's completely untested and feedback is
> very welcome.
Wow, that's cool. I figured that the body had also been completely
fetched by the time vcl_fetch is invoked, so that changes things
completely. I'll definitely give this a try.
BTW, is there any "cast" trick to be able to use arithmetic operators
like ">" with beresp.http.Content-Length (or other numeric headers)?
More information about the varnish-misc
mailing list