Professional Documents
Culture Documents
Varnish
Varnish
Programmers manual
What is Varnish
Varnish is an HTTP accelerator designed for content heavy dynamic web sites. It is a layer between HTTP frontend and application server(apache in our case). Popular client for varnish includes : Facebook,Globo,The Hindu etc. What is it not ? . Varnish is not replacement of other php performance tool like memcache, APC etc. varnish is just an addition to it.
Key Features
Fully Configurable Heavily Threaded Multiple backend handling
Serving assets (images/css/swfs...) from a lightweight backend whilst serving content from main server
Apache Benchmark
Apache benchmarking done on our local server
This will start varnish at port 2001. To Stop : pkill varnishd To Edit Varnish Default vcl file :Vim /etc/varnish/default.vcl
VCL
The VCL language is a small domain-specific language designed to be used to define request handling and document caching policies for the Varnish HTTP accelerator.
Backend declarations A backend declaration creates and initializes a named backend object:
Purging of cache
To purge varnish cache edit vcl : acl purge { "localhost"; "10.157.221.82"; "10.157.221.52"; "10.157.222.71"; } sub vcl_hit { if (req.request == "PURGE") { #set obj.ttl = 0s; ban_url(*); error 200 "Purged."; } } sub vcl_miss { if (req.request == "PURGE") { error 404 "Not in cache."; } } In vcl_fetch if(req.request == "PURGE"){ if(!client.ip ~ purge) { error 405 "Not allowed"; } } Bypassing CACHE if(req.url == "/varnishtest/randomnocache.php"){ return (pass) ; }
Thanks
Team Ninja
Anshuman ravi Anshuman.ravi@indiatimes.co.in