vcl question cookie

Dag-Erling Smørgrav des at linpro.no
Thu May 10 15:03:31 CEST 2007


jean-marc pouchoulon <jean-marc.pouchoulon at ac-montpellier.fr> writes:
> in fact I did
>
> if (req.url ~ "\.pdf$|\.png$|\.gif$|\.jpg$|\.mp3$|\.svf$") {
>        if (req.http.Authenticate || req.http.Cookie ~ "__ac=") {
>                pipe;
>        }
>        lookup;
> }
>
> I suppose pipe also terminates vcl_recv() I tried also
>
> if (req.url ~ "\.pdf$|\.png$|\.gif$|\.jpg$|\.mp3$|\.svf$" &&
>     !(req.http.Cookie ~ "__ac=")) {
>         lookup;
> }
>
> it seems slow

What seems slow?  Does Varnish actually run slowly, or do you just think
the code looks slow?

> Any workaround to accomplish partial cache with cookies ?

Not sure what you're asking for.

If (as in most cases) neither authentication nor cookies actually make
any difference as far as images are concerned, you might as well ignore
them completely:

if (req.url ~ "\.pdf$|\.png$|\.gif$|\.jpg$|\.mp3$|\.svf$") {
       lookup;
}

BTW, your regexp could be more readable:

if (req.url ~ "\.(pdf|png|gif|jpg|mp3|svf)$") {
       lookup;
}

depending on your OS's regexp library, it might also be faster that way
(though you probably won't notice)

DES
-- 
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no



More information about the varnish-misc mailing list