Varnish Accelerate Website Through Caching

Website are served through several back-end. Most website uses Apache, PHP and MySQL. Apache is the web server. PHP is the application controller and MySQL is the database for data storage. They all have limitation on how many times per second it can be accessed. For high traffic website, it is necessary to reduce the access to those elements. How to do it ?

One of the most common things is to setup a cache that stores frequently accessed content. This can be javascript file, css stylesheet and images. Varnish Cache is one of those that cache these.

Varnish works by becoming a front-end to Apache. So, all request for the website pages are going through Varnish. If the webpage exists, then Varnish will serve directly the webpage from its cache. This greatly reduce load on Apache, PHP and MySQL.


Varnish also store the cache in memory, which means a lot faster access. Compared to disk based cache.

Now, if the cache for the webpage does not exists, Varnish will contact the Apache to get the requested page. It will then store it in Varnish cache, so the next time the page is requested, it will be served directly by Varnish.


There is one catch though, you need to have access to the web server, since you do need to configure Apache to use Varnish. It also requires technical knowledge to setup.

But, if you want to give it a try, you can follow steps outlined in Smashing Magazine.