[Varnish] #277: rfc2616.c marks expired content as acachable

Varnish varnish-bugs at projects.linpro.no
Fri Jul 18 05:06:20 CEST 2008


#277: rfc2616.c marks expired content as acachable
----------------------+-----------------------------------------------------
 Reporter:  richardc  |       Owner:  phk            
     Type:  defect    |      Status:  new            
 Priority:  normal    |   Milestone:                 
Component:  varnishd  |     Version:  trunk          
 Severity:  normal    |    Keywords:  caching rfc2616
----------------------+-----------------------------------------------------
 I've been trying to get varnishd to not cache certain dynamic pages in my
 website. After spending some time reviewing the code in rfc2616.c adding
 additional logging and experimenting with cache control headers I have
 come to the conclusion that the code does not detect content with expiry
 dates in the past, as not cacheable.

 Near the bottom of RFC2616_cache_policy():
 {{{
 sp->obj->ttl = RFC2616_Ttl(sp, hp, sp->obj);
 if (sp->obj->ttl = 0) {
     sp->obj->cacheable = 0;
 }
 }}}

 The object is marked as not cacheable if RFC2616_Ttl() returns zero,
 however RFC2616_Ttl() returns the time to die as a unix timestamp. Instead
 I am using:
 {{{
 sp->obj->ttl = RFC2616_Ttl(sp, hp, sp->obj);
 if (sp->obj->ttl <= sp->obj->entered) {
         sp->obj->cacheable = 0;
 }
 }}}
 However, RFC2616_Ttl() tries to detect clock skew, which has the effect
 that it never returns a time in the past. I have relaxed this clock skew
 detection by changing line 142 from:
 {{{
     if (h_date < obj->entered && h_expires > obj->entered) {
 }}}
 to:
 {{{
     if (h_date <= obj->entered) {
 }}}

 This seems to do the trick.

 I've also observed that RFC2616_Ttl() does not pay any attention to
 "Pragma: no-cache", and "Cache-Control: no-cache, must-revalidate"
 headers.

 I'm not an expert on RFC2616 and wouldn't be surprised if this was not
 standard compliant, however it is standard practice to use dates from the
 past, along with a plethora of cache control headers to stop pages from
 being cached.

-- 
Ticket URL: <http://varnish.projects.linpro.no/ticket/277>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator


More information about the varnish-bugs mailing list