Pages

Subscribe:

Friday, December 12, 2014

Understanding Varnish Cache

This is in continuation to my previous post on Reverse proxy servers.

Varnish is a caching http reverse proxy which means it works as an intermediatery between your client and web server, receives the requests from the client and tries to answer them from the cache , In case if varnish is not able to answer the request from the cache it will forward the request to the backend web server and fetch the response  while storing the response in it cache and delivering the response to the client.



It may be understood as when a  user first time visits the website and requests the page , varnish keeps the copy of the served page and when the user re-visit the same page again, it gets served from the saved copy of the page from the varnish cache instead of re-requesting the page from the web server, Which improves the website's performance and scalability and improves response time.




Varnish cache response is highly responsive and is very faster than the typical backend server, so you want to make sure maximum number of requests are served directly from the varnish cache itself which can typically deliver the speeds up to 300 - 1000x , depending on the architecture.

Varnish cache decides whether it can store the content or not based on the response it receives from the backend in the form HTTP response header Cache-Control. Though there are few conditions were varnish will not cache content , the most common being the use of the cookies since the cookies indicates the client-specific web object, so by default varnish will not cache it.

You can customize most of the varnish functionality by changing the policies written in the Varnish Configuration Language (VCL). Using VCL you can write policy by which you can decide what content you want to server, from where you want to get the content and how the request or response should be altered, thereby giving huge customization options according to your need.

Varnish supports all modern day platforms and is a community driven project and delivered under EPEL package repository.


0 comments:

Post a Comment