vcl to avoid caching 404

Geoff Simmons geoff at uplex.de
Tue Apr 5 17:38:40 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 04/ 5/11 05:20 PM, Jonathan Leibiusky wrote:
> Hi!
> I am trying to configure varnish to avoid caching some specific http
> statuses sent from the backend. Since I can't control 100% the headers they
> are sending, I should do it in varnish as they all go through it.
> What I came with is:
> 
> sub vcl_fetch {
>     if (obj.status == 404 || obj.status == 503 || obj.status == 500) {
>         set obj.http.Cache-Control = "max-age=0";
>         return (pass);
>     }
>     return (deliver);
> }
> 
> But when I try to run varnish it complains about not being able to compile
> vcl:
> 
> Message from VCC-compiler:
> Variable 'obj.status' not accessible in method 'vcl_fetch'.

Try 'beresp.status' instead of 'obj.status'. And you'll need to assign
to beresp.http.Cache-Control as well.

'obj' in vcl_fetch() was changed to 'beresp' in Varnish 2.1 or thereabouts.


Best,
Geoff
- -- 
** * * UPLEX - Nils Goroll Systemoptimierung

Schwanenwik 24
22087 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (SunOS)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNmzeAAAoJEOUwvh9pJNURGSQP/1KuagJMYRPPszQJwB2nuWL7
U6ccUxK2cyznsVlvL5SF7JDE6GTBv4bTy50INBHPIV0z7d6JI3IQ1XBPpt1EDIZ4
IuQRZXKc2XuLdK7sfhCUiKQxrOYJOjmrhiASCUJdT7Waj73oP4cfNMJVzwcuZwZI
ZGm6zwjGRreohdELuXeaxF1+fTCxDkH7PkKVYSZKuzF0u0uU/q78V7moGctqU9t0
U6TJjEQO2cO0qHLMJtwh28tAjepKQNs5FO0zR2VwlgwEW4AvQzgjx4t5YnWouXXM
VJQSL9MljvsQYjBYth9A59F7ZHXQ9Fbvii+v3Fzay7S8SzBB3Rr+a+zefj5Ep0nR
wm5TAYoXfZ5XmV30uhFxKKE6SXGW1v/ibtUiLaNAemjRdjBk+ozwpkjAepHRNk4x
olLz0lepJSC04ZsMD77bzmA+7dFWYs8/SdoOCZrUgkjUo2lHOqyz+cRPoNFZApBG
RRBvIZdBO+cGS1eesu05QabtE6VSWkuf30quh/rxkFmh3GsDsbftwQDcq1OOyDWW
cBOK1eemNQJCgykAIiVSeWKsKYsi+2MlR+sX1chJE6Fi5aiH9VjN/7oRAV/1GnLW
TDdZ9pCAJd5UxNKKp5LEC+XH38ZD9EHfvxMK9JfJDPxgBqfOj5Yzk9tBlygTSpqk
+K6Cb/7V8qLzv7NS8gYA
=uXwP
-----END PGP SIGNATURE-----




More information about the varnish-misc mailing list