Member-only story
How to clear the cache?
There are few ways to clear Varnish’s cache:
ttl
setting timed setting- purge Clear cache for one object
- ban Reservation of cache clear using regular expression
SmartBan
- set
req_hash_always_miss = true
Clear cache for a URL - purge method available from varnish v4
- Only
SmartBan
can clear the cache at once, otherwise,ttl
timed by default, the cache is cleared for 2 minutes
SmartBan configuration and testing
BAN method does not clear the cache immediately, but sets the target cache to BAN, and the next time the URL is requested, it behaves like reading to the backend server.
When a method request called BAN is sent, all html under the /example
directory and the cache of /example.html
are put in the ban, that is, it is set to be acquired in the backend the next time it is accessed.
Change timeout due to cache target
If we want to change the cache time depending on the content, we can do it in default.vcl
.
sub vcl_fetch {…