0

We have a website which is fairly large. we update content every week but it is fine to serve stale for the first visit after updating backend content. Therefore we dont want to ban or purge whole cached content in varnish which make whole websites slowly for the first visit. So is there anyway to tell Varnish to stale whole cached content without clearing them already until someone visit and Varnish will fetch content in background?

Edited : I read about BAN command in Varnish however the document doesn't write it very clearly. I'm not sure if the cached content will be marked as stale and Varnish will still serve it for the first visit while fetching fresh content from backend or Varnish will force waiting for new fresh content from backend for the first visit ?

Tung
  • 1
  • 1

1 Answers1

0

You're literally talking about grace mode:

Setting an object’s grace to a positive value tells Varnish that it should serve the object to clients for some time after the TTL has expired, while Varnish fetches a new version of the object.

Danila Vershinin
  • 5,286
  • 5
  • 17
  • 21
  • Not really, I know this grace mode however lets assume we have Varnish with cached content with very long TTL already. Now I have fresh content in backend which I want Varnish to fetch. However I don't want to remove cached content which make the website slow, I want to tell Varnish to stale content only so first visit still get staled content from Varnish while Varnish fetch fresh content from backend asynchronously. – Tung Apr 10 '23 at 11:41
  • Then you're talking about [`softpurge`](https://varnish-cache.org/docs/7.1/reference/vmod_purge.html#purge-soft). – Danila Vershinin Apr 12 '23 at 16:45