• +62 (081) 322 209080
  • Choose your language:
  • id


Insights and ideas for software startups. We provide advice and insights for entrepreneurs.


Varnish – Remove file(s) from the cache

Varnish caches files. So if you replace a file on the server by a new one and this file is not refreshed when you try to access to it via your browser it probably means that Varnish still keep an expired version in his cache. (Or you didn’t clear the cache of your browser)

To purge a file from the cache, here is the process:
- Log in the varnish that manage this file.
- Check on what port the varnish CLI is running (example
# ps -ef | grep varnish
- Connect to the CLI using varnishadm. It should looks like something like this :
# sudo varnishadm -T -S /etc/varnish/secret
- Once you are connected you have to give the URL of file(s) you want to purge. You have to use regular expression :
-> Imagine that you want to purge this image : http://static.mauitu.com/images/bg-footer.jpg the command will be :
url.purge ^/images/bg-footer.jpg$

-> if you want to purge all the images contained in /images :
url.purge ^/images/$
 this will purge all the the images folder
-> if you want to purge all the images contained in /images and his subdirectories:
url.purge ^/images/
this will purge all the the images folder.
This will purge the cache for the file after his next call. Then all the other request to the fille will hit the cache just like before. So if you decide to modify again a file, you will have to type thos command again
To exit the varnish CLI type :

Antoine Leboulanger…

Full time Entrepreneur, Startup enthusiast, designer, programmer, system and network admin, "Expert in Network and System Engineering", yeap it's written on his degree...