Varnish is a HTTP proxy cache or an HTTP accelerator designed to cache http requests to make dynamic websites a lot faster. Varnish is used by high-profile, high-traffic websites including online newspaper sites
The principal configuration mechanism is Varnish Configuration Language (VCL)
############# Installation for centos/redhat/fedora ####################
yum install varnish
*** Listen port should be 80 and Assing our Allocate Memory of 512 MB for caching
vi /etc/sysconfig/varnish
VARNISH_LISTEN_PORT=80
VARNISH_VCL_CONF=/etc/varnish/default.vcl
VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=80
VARNISH_MIN_THREADS=1
VARNISH_MAX_THREADS=1000
VARNISH_THREAD_TIMEOUT=120
VARNISH_STORAGE_SIZE=512M
VARNISH_STORAGE=”malloc,${VARNISH_STORAGE_SIZE}”
VARNISH_SECRET_FILE=/etc/varnish/secret
VARNISH_TTL=120
vi /etc/varnish/default.vcl
Modify the default backend default port 80 to port 81 instead, so the backend section should look like the following
backend default {
.host = "127.0.0.1";
.port = "81";
}
Edit the apache httpd.conf to configure apache to listen on port 81 instead
vi /etc/httpd/conf/httpd.conf
Listen 81
service httpd restart
chkconfig varnish on
service varnish start
Test Varnish
------------
yum install curl
curl -I http://localhost
or
Browse a page from this server by firefox with firebug .... (Install firefox and also firebug addon)
Try visiting your site and refresh the page multiple times to make sure it was cached, then using firebug go to the Net tab you should see under the fetched resources that it was served by varnish
visit site and refresh by F5 several times..->click firebug -> click "net" tab -> click cache header
No comments:
Post a Comment