Checking http response codes
cripy
ccripy at gmail.com
Wed May 30 17:55:53 CEST 2007
It's currently not possible to do this in VCL that I know of...I have come
up with a solution for a similar issue I had with varnish cache'ing 401
Unauthorized responses, thus denying legit authenticated users the proper
content because they are being serviced the 401. What I did is jumped into
the function cnt_fetch in bin/varnishd/cache_center.c here's a snippet...
--- /tmp/clean/varnish-1.0.4/bin/varnishd/cache_center.c 2007-05-20
10:38:16.000000000 -0700
+++ cache_center.c 2007-05-23 14:55:43.000000000 -0700
@@ -286,7 +286,8 @@
cnt_fetch(struct sess *sp)
{
-
+ struct vbe_conn *vc;
+
if (Fetch(sp)) {
sp->obj->cacheable = 0;
HSH_Unbusy(sp->obj);
@@ -300,6 +301,11 @@
RFC2616_cache_policy(sp, &sp->obj->http); /* XXX -> VCL */
VCL_fetch_method(sp);
+ vc = VBE_GetFd(sp);
+
+ if (http_GetStatus(vc->http) == 401)
+ sp->handling = VCL_RET_PASS;
+ VBE_ClosedFd(sp->wrk, vc, 0);
if (sp->handling == VCL_RET_ERROR)
INCOMPL();
@@ -353,6 +359,64 @@
sp->step = STP_DONE;
return (0);
}
On 5/30/07, Thomas Westlund <thomas.westlund at aftenposten.no> wrote:
>
> Hi,
>
> I'm having av bit of keyboard trouble this morning, so forgive me if i
> post this question more than once, (too early still perhaps ;)
>
> If I would like to do a check based on the response code from the backend
> how can I do this in VCL
>
> I would like to be able to not cache 404's or to set the timeout to a very
> low number for 404's.
>
> I have checked the vcl man page, but I'm unable to find which statement to
> use for the if clause
>
> --
>
> Thomas Westlund
> Aftenposten AS, UNIX/nettverksavd.
> Postboks 1, 0051 Oslo
> Tlf: +47 98 20 30 33
> Fax: +47 22 86 40 74
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20070530/7eaa44ca/attachment-0001.html>
More information about the varnish-misc
mailing list