VCL not cache but deliver

Daniel Parthey pada at posteo.de
Mon May 23 00:22:39 CEST 2016


Am 22.05.2016 um 13:54 schrieb dserwin:
> I have question related to Varnish VCL. I want to write vcl which under
> some conditions will not be caching object downloaded from backend but
> only deliver it to the client. I was trying to use vcl_backend_response
> subroutine, but returning (abandon) results in returning 503 Service
> Unavailable to the client. I'm using varnish 4.1.2.

Abandon aborts the backend fetch, see the state diagram:
https://www.varnish-cache.org/docs/4.1/reference/states.html

You don't want to cancel the download from backend, you want
to tell varnish not to cache the object, but to deliver it.

In vcl_backend_response you can
set beresp.uncacheable = true;
in order to prevent caching of the fetched object.

See https://www.varnish-cache.org/docs/4.1/reference/vcl.html

Example:

sub vcl_backend_response {
    if (put your condition here) {
        set beresp.uncacheable = true;
        return (deliver);
    }
}

Kind regards
Daniel
-- 
https://emailselfdefense.fsf.org
https://pgp.mit.edu/pks/lookup?op=get&search=0xB4DD34660B6F0F1B
https://pgp.key-server.io/0xB4DD34660B6F0F1B
Fingerprint: 366C BC38 B09B 4BFC 38A7  3CBC B4DD 3466 0B6F 0F1B

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160523/0f005170/attachment.pgp>


More information about the varnish-misc mailing list