I have not tried this before on Varnish. And I must admit that my last experience with Varnish was way back - version 2.1.5 days!
I have set varnish 6.x as a simple/basic static http-cache. I have achieved most of what I wish to from this varnish, and then I had an idea to display cache-ttl info as response header. Here, I hit a roadblock. I am surely doing it incorrectly. Possibly vcl_delivery may not get beresp.ttl. I am not sure. This is what I added to vcl_deliver
set resp.http.X-TTL = "TTL (" + beresp.ttl +")";
I get compile error:
Mar 19 07:05:41 varnishd[55516]: Message from VCC-compiler:
Mar 19 07:05:41 varnishd[55516]: ('/etc/varnish/default.vcl' Line 97 Pos 40) -- (Pos 49)
Mar 19 07:05:41 varnishd[55516]: set resp.http.X-TTL = "TTL (" + beresp.ttl +")";
Mar 19 07:05:41 varnishd[55516]: ---------------------------------------##########------
Mar 19 07:05:41 varnishd[55516]: Not available in method 'vcl_deliver'.
I tried assigning beresp.ttl as header variable in vcl_backend_response:
set beresp.http.x-ttl = beresp.ttl
That did not work either.
Makes me wonder, if this is possible? If so, how to achieve it?