Setup Varnish for Magento

From Brian Nelson Ramblings
Jump to: navigation, search

Setting Varnish with Magento

Varnish will working without using extensions, but with eCommerace sites, you do not want to cache your shopping cart or wishlists. Fortunately Nexcess has developed a free and open-source Magento-Varnish extension called Turpentine that has solved this problem. Not only does this extension have great features like allowing custom exceptions for different routes and allowing users to purge the cache from the Magento Admin, it also comes with pre-configured VCL configs for Varnish 2.1 and 3.0, making implementation easy.

Start off by install varnish on your server

You can follow the guide to install varnish Click Here

Setting Up Magento to Control Varnish

There are number of extensions that you can use to setup varnish but one of the most talked about is Turpentine

Now you can do this a number of ways, but the fastest is via the command line, since we are already there to setup varnish

./mage install Nexcessnet_Turpentine

The exension will be installed under app/code/community/Nexcessnet/Turpentine/. As mentioned, the configuration VCL is automatically generated by the Turpentine extension, so we don’t need to worry about editing it manually.

Now, login to the Magento Admin Panel and go to

System -> Configuration -> turpentine -> Varnish Options

Backend Host -> Backend Port -> 81

You will also need to get your Varnish authentication Key

cat /etc/varnish/secret

Copy and Paste that into your Varnish authentication key

Now -> Click Save Config

Last step is symlink the default.vcl to your Magento store

cd /etc/varnish && cp default.vcl default.vcl-bk
ln -s /path/to/magento/var/default.vcl default.vcl
/etc/init.d/varnish restart

Additional Articles