Install and Configure Varnish Cache on Linux

[dropcap]I[/dropcap]t is a very difficult task to increase the performance of a website having heavy content. Varnish Cache is an open source web application accelerator for such heavy content websites to improve their performance significantly. It will accelerate your website performance up to 80%. It’s really a Cool/Nice tool. When a webpage of your website loads for the first time, varnish keeps a copy of the same page and when some user requests for the same page varnish gives them the copied page instead of regenerating/ reprocessing for the page on the webserver.

How to install Varnish on Fedora/CentOS/RHEL
# wget rpm --nosignature -i varnish-release-3.0-1.noarch.rpm# yum install varnish
How to install Varnish on Ubuntu
# wget apt-key add GPG-key.txt# echo "deb precise varnish-3.0" | sudo tee -a /etc/apt/sources.list# sudo apt-get update# sudo apt-get install varnish
To start the Varnish Cache Issue the below commands
# chkconfig --level 345 varnish on# /etc/init.d/varnish start
To configure Varnish we need to edit the /etc/varnish/default.vcl file. This file contains all the varnish configuration.
backend default {.host = "";.port = "80";}
Now we finish almost our configurations. To start varnish cache we have to restart the vanish and apache services.
# /etc/init.d/httpd restart# /etc/init.d/varnish restart
To verify Varnish you can issue below command
# curl -I

HTTP/1.1 200 OK
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Vary: Accept-Encoding
Cache-Control: max-age=7200, must-revalidate
Content-Type: text/html; charset=UTF-8
Date: Mon, 25 Feb 2013 17:01:57 GMT
X-Varnish: 796827437
Age: 0
Via: 1.1 varnish
Connection: keep-alive
Reference :

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

2 thoughts on “Install and Configure Varnish Cache on Linux

Leave a Reply