2
votes

I'm trying to use varnish to cache rpms and other giant binaries. What I would've expected is that when an object is expired in the cache varnish would send a request with If-Not-Modified to the backend and then assuming the object didn't change, varnish would refresh the ttl on the local cached object without downloading a new one. I wrote a test backend to generate specific request (set small max-age and whatnot, as well as see the header varnish sends) but I never get anything else then full fetch. If-Not-Modified is never sent. My VCL is basically the default VCL. I tried playing around with setting small ttl/grace but never got any interesting behavior.

Is varnish even able to do what I want it to ? If so has anyone done anything similar and can give tips ?

1
On setting a small TTL, check out jakearchibald.com/2016/caching-best-practices for some good idea's on how to cache content.Samuel Parkinson

1 Answers

0
votes

The request sent to the backend when an object is expired is the one that Varnish receives from the client.

So when testing your setup, are you sending an If-Not-Modified header in your requests to Varnish?

Have a look at https://www.varnish-software.com/wiki/content/tutorials/varnish/builtin_vcl.html to see what the built in VCL is.

Under vcl_backend_fetch, which will be called if there is no object in the cache, you can see there is no complex logic around stale objects, it is just passing on the request as is.