varnish regex

Michael Loftis mloftis at wgops.com
Wed Nov 10 18:20:57 CET 2010


On Wed, Nov 10, 2010 at 9:56 AM, Vitaly Burshteyn
<vburshteyn at broadway.com> wrote:
> Hi folks,
>
>
>
> I have a set of url’s that I need to make sure that varnish does cache.  The
> url patern looks like this:
>
>
>
> Siteurl/r/anynumber
>
>
>
> if (req.url ~ "/r/*/") {
>
>         return(pass);
>
>     }
>
>
>
>
>
> Or
>
>
>
>
>
> if (req.url ~ "^/r/\d+/$") {
>
>         return(pass);
>
>     }
>
>
>
>
>
> Sorry about this question, but I am not sure how varnish processes regex
> values.


First, return (lookup) not pass.  Lookup pushes it into the cache
hash/lookup routine for a fetch/hit.  Secondly if there's no trailing
/ in your requested URLs, then make sure it doesn't appear in your
pattern either.  The regular expression flavor is PCRE/libpcre.

Even if you return lookup you're not guarenteed to cache.  POSTs,
things with cookies don't get cached.
http://www.varnish-cache.org/docs/2.1/reference/vcl.html for VCL
reference and the default VCL.




More information about the varnish-misc mailing list