VCL question - where is cacheability determined?

David Miller meetheus at gmail.com
Wed Jan 25 18:19:51 CET 2012


I'm converting from 2.1 to 3.0.  I got bit by the beresp.cacheable variable
going away, and replacing it with beresp.ttl > 0s doesn't work because ttl
hasn't been determined yet; it's a -1.000.

This is the block of code in question (in vcl_fetch)

        if (!beresp.cacheable && beresp.status != 404) {
                set beresp.http.X-Cacheable = "NO: !beresp.cacheable";
                return (pass);
        } else {
                # From http://varnish-cache.org/wiki/VCLExampleLongerCaching
                /* Remove Expires from backend, it's not long enough */
                unset beresp.http.expires;
        }

If beresp.ttl hasn't been determined yet, what's the appropriate
replacement?

On a related note, I was looking at the source code for 2.1.  From my quick
reading, it looks like beresp.cacheable is determined by request type and
return status.  I don't see where apache/drupal/web-server cache headers
are consulted at all.

Am I missing something there?  Are back-end cache headers to be parsed in
VCL rather than being automagically determined?

TIA,

--- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120125/09dd280b/attachment.html>


More information about the varnish-misc mailing list