[Varnish] #570: [2.0.4] Strange behaviour when using If-Modified-Since
Varnish
varnish-bugs at projects.linpro.no
Fri Oct 23 19:40:44 CEST 2009
#570: [2.0.4] Strange behaviour when using If-Modified-Since
------------------------+---------------------------------------------------
Reporter: gdelacroix | Owner: phk
Type: defect | Status: new
Priority: normal | Milestone:
Component: varnishd | Version: 2.0
Severity: normal | Keywords:
------------------------+---------------------------------------------------
Hi !
When sending a request with "If-Modified-Since" header in pass mode to a
backend that does not correctly handle this header (never responds 304),
it seems that Varnish (2.0.4) overrides this behaviour by replacing (when
necessary) 200 with 304 and does not send any content => This is great !
But it seems that, when doing this, Varnish follows a different path that
forgets headers that are set in vcl_fetch...
Here is my vcl_fetch sample :
{{{
vcl_fetch {
if (req.http.Host == "www.site1.com") {
set obj.http.MyTag = "Site1";
} elseif (req.http.Host == "www.site2.com") {
set obj.http.MyTag = "Site2";
}
}
}}}
In most cases (if backend sends 304 or no 304 is necessary), "MyTag"
header will be sent.
But only if the backend answers 200 but it should have answered 304 (Last-
Modified <= If-Modified-Since), then Varnish will correct this and send
304 without data, but "MyTag" header will not be sent...
I have tried to add some kind of :
{{{
vcl_delivery {
if (req.http.Host == "www.site1.com") {
set resp.http.MyTag = "Site1";
}
...
}}}
but vcl_delivery doesn't handle req.http...
Here is some varnishlog to give you more details : (same requests, same
VCL, only backend configuration changes)
Normal behaviour (304 > 304) :
{{{
11 RxProtocol b HTTP/1.1
> 11 RxStatus b 304
11 RxResponse b Not Modified
11 RxHeader b Connection: Keep-Alive
11 RxHeader b Date: Fri, 23 Oct 2009 17:20:13 GMT
11 RxHeader b ETag: "d022b2771de7c81:14ff"
11 RxHeader b Server: Microsoft-IIS/6.0
11 RxHeader b Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
11 RxHeader b Accept-Ranges: bytes
11 RxHeader b X-Powered-By: ASP.NET
7 ObjProtocol c HTTP/1.1
> 7 ObjStatus c 304
7 ObjResponse c Not Modified
7 ObjHeader c Date: Fri, 23 Oct 2009 17:20:13 GMT
7 ObjHeader c ETag: "d022b2771de7c81:14ff"
7 ObjHeader c Server: Microsoft-IIS/6.0
7 ObjHeader c Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
7 ObjHeader c X-Powered-By: ASP.NET
11 BackendReuse b MyBackend
7 TTL c 110064484 RFC 3600 1256318401 0 0 0 0
7 VCL_call c fetch
7 VCL_return c pass
7 Length c 0
7 VCL_call c deliver
7 VCL_return c deliver
7 TxProtocol c HTTP/1.1
> 7 TxStatus c 304
7 TxResponse c Not Modified
7 TxHeader c ETag: "d022b2771de7c81:14ff"
7 TxHeader c Server: Microsoft-IIS/6.0
7 TxHeader c Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
7 TxHeader c X-Powered-By: ASP.NET
7 TxHeader c Content-Length: 0
> 7 TxHeader c MyTag: Site1
7 TxHeader c Date: Fri, 23 Oct 2009 17:20:01 GMT
7 TxHeader c X-Varnish: 110064484
7 TxHeader c Age: 0
7 TxHeader c Via: 1.1 varnish
7 TxHeader c Connection: keep-alive
7 ReqEnd c 110064484 1256318401.559283018 1256318401.564701557
0.010328531 0.005382299 0.000036240
}}}
Strange behaviour (200 > 304) :
{{{
11 RxProtocol b HTTP/1.1
> 11 RxStatus b 200
11 RxResponse b OK
11 RxHeader b Connection: Keep-Alive
11 RxHeader b Content-Length: 377
11 RxHeader b Date: Fri, 23 Oct 2009 17:27:19 GMT
11 RxHeader b Content-Type: image/gif
11 RxHeader b ETag: "d022b2771de7c81:1c82"
11 RxHeader b Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
11 RxHeader b Accept-Ranges: bytes
7 ObjProtocol c HTTP/1.1
> 7 ObjStatus c 200
7 ObjResponse c OK
7 ObjHeader c Date: Fri, 23 Oct 2009 17:27:19 GMT
7 ObjHeader c Content-Type: image/gif
7 ObjHeader c ETag: "d022b2771de7c81:1c82"
7 ObjHeader c Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
11 BackendReuse b MyBackend
7 TTL c 110064485 RFC 3600 1256318831 0 0 0 0
7 VCL_call c fetch
7 VCL_return c pass
7 Length c 0
7 VCL_call c deliver
7 VCL_return c deliver
7 TxProtocol c HTTP/1.1
> 7 TxStatus c 304
7 TxResponse c Not Modified
7 TxHeader c Date: Fri, 23 Oct 2009 17:27:11 GMT
7 TxHeader c Via: 1.1 varnish
7 TxHeader c X-Varnish: 110064485
7 TxHeader c Last-Modified: Wed, 16 Jul 2008 08:25:12 GMT
7 TxHeader c Connection: keep-alive
7 ReqEnd c 110064485 1256318831.177328587 1256318831.183318853
0.003719568 0.005955219 0.000035048
Where is MyTag ??
}}}
It would be great if someone could explain me some fix or some
workaround...cause I really miss MyTag ;o)
Thanks !
--
Ticket URL: <http://varnish.projects.linpro.no/ticket/570>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list