Deleting Cached file/url from Varnish

Sometimes you might want to delete a file/url from varnish because it has been updated. Its pretty easy. Eg: bukalapak previously store KTP (literally: Resident Identity Card), we don't want it anymore so we need to delete image files that has been stored inside varnish. So, this is how I did it.

Get into varnish CLI

Issue this command.

# sudo varnishadm

You will get this output.

root@salya:/home/syseng# varnishadm  
Varnish Cache CLI 1.0  
varnish-4.0.3 revision b8c4a34

Type 'help' for command list.  
Type 'quit' to close CLI session.

Delete Uri

You can use regex for the url you want, for example ban req.url ~ "logo.*[.]png". On my case, I use this command.

ban req.url ~ "/uploads/lalalal*"  

Aaand that's it.


Radio astronomer pretending to be system engineer.

Bandung, Indonesia