Varnish stripping Cache-Control header

Lars Wolff lars at renoz.dk
Wed Dec 8 14:24:37 CET 2010


Hi,

I have a problem with Varnish 2.1.4 stripping the Cache-Control header, 
which results in the client caching pages, that are not supposed to be 
cached (or to be more precise - locally storing them, allowing the back 
button to be served without a hit to the server).

The header looks like this (should be standard PHP session Cache-control).

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

I'm running FreeBSD, and this problem has been verified with the 
default.vcl.

Steps:

1. Restart varnishd
2. Hit the page - this time the Cache-Control header will be served to 
the client
3. Hit the page again - this time the Cache-Control header will be 
stripped by varnish. From now on it will be stripped.

varnishlog -b still reports:
...
    10 RxHeader     b Set-Cookie: 
PHPSESSID=ba69a435445f9d1b617951cb2ef00d35; path=/
    10 RxHeader     b Expires: Thu, 19 Nov 1981 08:52:00 GMT
    10 RxHeader     b Cache-Control: no-store, no-cache, 
must-revalidate, post-check=0, pre-check=0
    10 RxHeader     b Pragma: no-cache
...

But varnishlog -c reports:
...
     9 TxHeader     c Set-Cookie: 
PHPSESSID=1bf083ca11d321412cce8155e593fe86; path=/
     9 TxHeader     c Expires: Thu, 19 Nov 1981 08:52:00 GMT
     9 TxHeader     c Pragma: no-cache
...

The result is not cached in varnish due to the Cookie - which is exactly 
as it should be.

First time after the restart varnishlog -c reports
...
     9 VCL_call     c recv
     9 VCL_return   c lookup
     9 VCL_call     c hash
     9 VCL_return   c hash
     9 VCL_call     c miss
     9 VCL_return   c fetch
     9 Backend      c 10 default default
     9 TTL          c 1643766043 RFC 0 1291814342 1291814342 375007920 0 0
     9 VCL_call     c fetch
     9 VCL_return   c pass
...
     9 VCL_call     c deliver
     9 VCL_return   c deliver
...

But after the first requests it reports:
...
     9 VCL_call     c recv
     9 VCL_return   c lookup
     9 VCL_call     c hash
     9 VCL_return   c hash
     9 HitPass      c 1643766043
     9 VCL_call     c pass
     9 VCL_return   c pass
...
     9 VCL_call     c fetch
     9 VCL_return   c pass
...
     9 VCL_call     c deliver
     9 VCL_return   c deliver
...

So its cached as a pass - fine, but this is where I dont understand 
whats happening. It fetches the page corrently from the server, and then 
removed the Cache-Control header.

Why?

This was not a problem in the past - I think it was version 2.1.2 or 
2.1.3 when it worked, so I have a feeling that this might be a bug.

Best regards
   Lars

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20101208/3c6c9b83/attachment-0003.html>


More information about the varnish-misc mailing list