cache empties itself?

DHF varnish-list at
Thu Apr 3 19:47:49 CEST 2008

Michael S. Fischer wrote:
> On Thu, Apr 3, 2008 at 10:26 AM, Sascha Ottolski <ottolski at> wrote:
>>  All this with 1.1.2. It's vital to my setup to cache as many objects as
>>  possible, for a long time, and that they really stay in the cache. Is
>>  there anything I could do to prevent the cache being emptied? May be
>>  I've been bitten by a bug and should give the trunk a shot?
> Just set the Expires: headers on the origin (backend) server responses
> to now + 10 years or something.
If you're not using php or some other cgi app, you can set headers using
mod_headers in apache, if you are running a web app, just set the
headers within the app itself.  You can also explicitly set the ttl on
objects in the cache using vcl code, but moving the load off the cache
to the backend makes more sense since you'll be cutting traffic down to
apache and it would free up cycles to modify headers.  If you have your
heart set on making varnish do the work you could add something like this:

sub vcl_fetch {
        if (!obj.valid) {
        if (!obj.cacheable  ) {
        if (obj.http.Set-Cookie) {
        if (req.url ~ "\.(jpg|jpeg|gif|png)$") {
                set obj.ttl = 31449600;

But I would first look at getting apache to set the age correctly and
leave varnish to do what its good at.


More information about the varnish-misc mailing list