Conditional caching question

Barry Abrahamson barry at
Thu Jun 5 08:03:15 CEST 2008

On Jun 2, 2008, at 8:41 AM, Poul-Henning Kamp wrote:

> In message <4841723E.2020109 at>, David Pratt writes:
>> Hi. In most cases, I want a request to be passed to a backend where  
>> it
>> will be handled by server. If frequency is high, however; I want to  
>> add
>> the object to varnish cache and have varnish handle it. I am not  
>> worried
>> about a mechanism to keeping track of frequency of requests.  
>> Question is
>> what is available to me to add an object/path to the varnish cache  
>> if it
>> was originally passed?
> I wouldn't say that your way of using varnish is backwards relative
> to the design objectives, but you do come close, since we assumed
> caching by default, and pass as exception, rather than the other
> way around.

We do this on to avoid filling our caches with  
infrequently requested data.  The way we handle it is when an object  
reaches a certain req/sec threshold, we send a header from the backend  
and then have varnish configured to only insert objects into the cache  
which contain this custom header.  Based on phk's reply, I guess we  
are using varnish in a somewhat backwards manner as well, since we  
assume pass as the detault, insert as the exception.

This used to work in 1.0.3.  I have started to look into upgrading to  
trunk, and it doesn't seem to work so well anymore.  It looks like the  
first time the URL is requested, if it is passed because it hasn't  
reached that threshold and the header hasn't been set, all subsequent  
requests are automatically "pass" ed.  These show up as "Cache hits  
for pass" in varnishstat.  Any way around this?

Barry Abrahamson | Systems Wrangler | Automattic

More information about the varnish-misc mailing list