0
votes

I have a very simple site and am setting up varnish cache on it. The server is nginx.

The cache seems to get automatically purged after 120 seconds as when I go on the site i see the Age header being reset.

Can anyone point me towards where to remove this and have pages cached indefinitely or until i manually purge varnish?

2

2 Answers

0
votes

You did not mention your OS or distribution, but for example on CentOS /etc/sysconfig/varnish sets the defaults for Varnish. Amongst those defaults is VARNISH_TTL=120, which sets the default TTL to 120 seconds.

If you only wish to set a high TTL for all objects, you can just edit the default one in /etc/sysconfig/varnish.

0
votes

If the backend sends to the Varnish age headers, the Varnish will consider them as a real expiration date just like a web browser and will purge it's content when the header expires.

You should make sure that the backend doesn't send cache-control headers to the varnish and only the varnish will add cache-control headers when sending data to the browsers.