[experimental-ims] e0c87d4 Move the HTTP-conditional check up before we call vcl_deliver{}, there is plenty of opportunity to prevent conditional delivery in all the other vcl_*{}'s and there is a value in exposing the actual response.
Poul-Henning Kamp
phk at FreeBSD.org
Thu Dec 18 10:27:47 CET 2014
commit e0c87d41cf1fb90442d5c2cd524ab9f88cb06dc1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon May 21 12:09:02 2012 +0000
Move the HTTP-conditional check up before we call vcl_deliver{},
there is plenty of opportunity to prevent conditional delivery
in all the other vcl_*{}'s and there is a value in exposing
the actual response.
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index d96bd8e..48fdfe4 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -266,6 +266,15 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
}
HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
RES_BuildHttp(sp);
+
+ if (req->obj->response == 200
+ && req->http->conds && RFC2616_Do_Cond(sp)) {
+ req->wantbody = 0;
+ http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
+ http_Unset(req->resp, H_Content_Length);
+ http_Unset(req->resp, H_Transfer_Encoding);
+ }
+
VCL_deliver_method(sp);
switch (req->handling) {
case VCL_RET_DELIVER:
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index cd45945..f92ca81 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -234,17 +234,6 @@ RES_WriteObj(struct sess *sp)
req = sp->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp);
-
- if (req->obj->response == 200 &&
- req->http->conds &&
- RFC2616_Do_Cond(sp)) {
- req->wantbody = 0;
- http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified");
- http_Unset(req->resp, H_Content_Length);
- http_Unset(req->resp, H_Transfer_Encoding);
- }
-
/*
* If nothing special planned, we can attempt Range support
*/
@@ -265,6 +254,8 @@ RES_WriteObj(struct sess *sp)
if (req->res_mode & RES_GUNZIP)
http_Unset(req->resp, H_Content_Encoding);
+ WRW_Reserve(sp->wrk, &sp->fd, sp->req->vsl, sp->req->t_resp);
+
/*
* Send HTTP protocol header, unless interior ESI object
*/
More information about the varnish-commit
mailing list