!obj.cacheable passes?

Ricardo Newbery ric at digitalmarbles.com
Thu Mar 20 04:26:14 CET 2008


I'm looking at the default vcl and I see the following stanza:

          sub vcl_hit {
              if (!obj.cacheable) {
                  pass;
              }
              deliver;

According to the vcl man page:

      obj.cacheable
            True if the request resulted in a cacheable response.  A  
response
            is considered cacheable if it is valid (see above), the  
HTTP status
            code is 200, 203, 300, 301, 302, 404 or 410 and it has a  
non-zero
            time-to-live when Expires and Cache-Control headers are  
taken into
            account.


Something about this seems odd.  Perhaps someone can clear it up for me.

We drop into "vcl_hit" if the object is found in the cache -- before  
we attempt to fetch from the backend.  And a "pass" of course doesn't  
cache the response.  Why do we not attempt to cache the response if  
the copy in our cache is not "cacheable"?  Couldn't a subsequent  
response otherwise be cacheable?  In other words, shouldn't this  
stanza instead be something like this:

          sub vcl_hit {
              if (!obj.cacheable) {
                  fetch;
              }
              deliver;
          }

And let "vcl_fetch" determine whether the new copy should be inserted  
into the cache?

If I understand correctly, 'vcl_hit' cannot currently be terminated  
with 'fetch'.   Why is that?

Ric





More information about the varnish-misc mailing list