I would like to kindly ask if there's someone who can help me configure Varnish for Magento to reach far more hits. My current ratio from varnishstat is:

  1. cache_hit=271
  2. cache_miss=926

I'm kindly asking this because I've googled almost every site related to this theme, but 99.9% of configurations don't work because of outdated code.

Details of my set-up:

  • I use Varnish on port 80, Apache on port 81,
  • PageCache as Magento varnish module,
  • APC for PHP speed and Memcached for dynamic caching.
  • Load speed is about 1.5s on home-page (Pingdom.com average results) > USA ping & 2.5s > Europe.
  • Servers are located in Toronto, Canada.


This is my full VCL configuration > http://pastebin.com/885BzHCs (I just use xxx.xxx.xxx.xxx for my IPs) This is the info from the command (varnishtop -i TxHeader -I Cookie):

TxHeader Cookie: frontend=965b5...(*lots of numbers); adminhtml=3ae65...(*lots of numbers); EXTERNAL_NO_CACHE=1

"(*lots of numbers)" is just my adding to the info

Any idea how to avoid Varnish hitting this cookies? (If I got correctly the idea about avoiding Vanrish hitting the cookie and not caching the home page).

Thank you for any help!

  • Welcome to serverfault. Don't post in the answers section, click edit and update your question. This is a Q&A site not a forum. – gideon Mar 7 '12 at 17:17

I don't work with Magento, but here are some Varnish suggestions that have worked for me:

Check for Cookies

First, you should remove all cookies from hitting varnish, 'cos when varnish sees a cookie, it sends the request to the backend.

Use a command like this to see what cookies are being sent to the backend:

varnishtop -i TxHeader -I Cookie


Second, evaluate if you really need vcl_hash. If you don't have a reason for using it, comment it out.

Try these one at a time and see if your hit ratio improves.

HTH, good luck.

|improve this answer|||||
  • Thank you! Yeah, I clearly understand this functionalities, but I can't find any proper code to use it correctly (I mean to remove concrete cookies right). They have strange names etc, etc and I would be sad to break any Magento's core functionalities, that I can't see by simple testing the frontend. I would try your suggestions for sure! :) Thanks again! If anything comes to your mind, feel free to share, it would be greatly appreciated! – Tomas Mar 7 '12 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.