Question regarding vcl config
Dridi Boukelmoune
dridi at varni.sh
Sat Sep 26 16:55:25 UTC 2020
On Sat, Sep 26, 2020 at 4:41 PM Johan Hendriks <neuteboom.log at gmail.com> wrote:
>
> Hello all, I have inherited a varnish server. And I am a little confused about a few lines in that config.
>
> It has the following in vcl_recv
>
> # Don't cache if there are request cookies
> if (req.http.Cookie) {
> set req.http.X-Debug-Varnish-Nocache-Recv = "Got request cookie (" + req.http.Cookie + ")";
>
> return (pass);
> }
>
> if (req.url ~ "\.(png|gif|jpg|jpeg|ico|swf|css|js|pdf|ico|js|ogg|mp4)$") {
> unset req.http.cookie;
> }
> if (req.url ~ "^/(includes|images|templates)") {
> unset req.http.cookie;
> }
>
> So the first if block tells request with req.http.Cookie to pass to the backend.
> The second tells if the requested url ends with .png|gif|jpg|jpeg|ico|swf|css|js|pdf|ico|js|ogg|mp4 and so on to unset the cookie.
> But will these rules be executed or is the request already passed to the backend?
The return(pass) statement will definitely prevent the following code
to be executed.
You might want to move the first if block after the two others, but
it's hard to tell without prior knowledge of how the backend
behaves...
Dridi
More information about the varnish-misc
mailing list