Mailing List Archive

vcl question cookie
Helo all,

I 'm trying to limit the absence of caching with cookies.


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

if (req.http.Authenticate || req.http.Cookie ~ "__ac=") {
pipe;
}
}

This is not working , all is cached.
where am I wrong ?

thanks

jean-marc
vcl question cookie [ In reply to ]
jean-marc pouchoulon <jean-marc.pouchoulon at ac-montpellier.fr> writes:
> I 'm trying to limit the absence of caching with cookies.
>
> if (req.url ~ "\.pdf$|\.png$|\.gif$|\.jpg$|\.mp3$|\.svf$") {
> lookup;
>
> if (req.http.Authenticate || req.http.Cookie ~ "__ac=") {
> pipe;
> }
> }
>
> This is not working , all is cached.
> where am I wrong ?

"lookup" terminates vcl_recv(). The nested if statement is never
reached.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
vcl question cookie [ In reply to ]
> "lookup" terminates vcl_recv(). The nested if statement is never
> reached.
>
> DES
>
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

Any workaround to accomplish partial cache with cookies ?

thanks again

jean-marc
vcl question cookie [ In reply to ]
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