Conditional GETs

Ricardo Newbery ric at
Sun Jul 29 21:05:01 CEST 2007

On Jul 29, 2007, at 3:52 AM, Dag-Erling Smørgrav wrote:

> Ricardo Newbery <ric at> writes:
>> What happens when a client sends a conditional request (either INM or
>> IMS) and the content is not available in the Varnish cache?  I assume
>> that Varnish will just relay the original conditional request through
>> to the backend.
> No, it will strip the conditional header before requesting the page  
> from
> the backend.

Okay, I think I understand.  So with Varnish in front, using the  
default VCL, there is no set of circumstances that will ever result  
in a conditional request to the backend.  Correct?

But I can still change this behavior with a custom VCL.  Correct?

Would the following work:

# perpetually refresh my cache
vcl_timeout {

# hold on to cache for at least a day
vcl_fetch {
         if (obj.ttl < 86400s) {
                 set obj.ttl = 86400s;

# if not available in cache, pass client's IMS to backend
# and pass response back to client without caching
vcl_miss {
         if (req.http.If-Modified-Since) {

If I wanted to selectively apply the first two above, could I just  
leverage a few custom headers like so?

# selectively force a perpetually refreshing cache  (is "resp"  
available here?)
vcl_timeout {
         if (resp.http.X-Cache-Refetch) {

# selectively apply a local ttl without messing up downstream proxies
vcl_fetch {
         if (resp.http.X-Cache-TTL) {
                 set obj.ttl = resp.http.X-Cache-TTL;

More information about the varnish-misc mailing list