Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hello to serverfault users,

I would like to kindly ask someone to help me configure varnish for magento.

Using command: varnishtop -i TxHeader -I Cookie , following info show:

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

How can I remove this cookies using Varnish VCL configuration to cache the page?

Thanks for any help in this case!, would be greatly appreciated!

Tomas

share|improve this question
add comment

2 Answers

According to the Varnish-cache documentation you can use something like this. I've use similiar setups on other sites and it works like a charm!

sub vcl_recv {
  if (req.http.cookie) {
    set req.http.cookie = ";" + req.http.cookie;
    set req.http.cookie = regsuball(req.http.cookie, "; +", ";");
    set req.http.cookie = regsuball(req.http.cookie, ";(frontend|adminhtml|EXTERNAL_NO_CACHE)=", "; \1=");
    set req.http.cookie = regsuball(req.http.cookie, ";[^ ][^;]*", "");
    set req.http.cookie = regsuball(req.http.cookie, "^[; ]+|[; ]+$", "");

    if (req.http.cookie == "") {
      remove req.http.cookie;
    }
  }
}
share|improve this answer
    
Thank you very much. I would try this setup and let you know! Your answer is greatly appreciated! –  Tomas Mar 8 '12 at 11:40
    
if you simply want to remove the cookie entirely then the regsuball(...) is redundant, but please leave it in the answer as it's still a good vcl example for cookie modification if needed. –  Oneiroi Mar 8 '12 at 12:30
    
I've tested this configuration and I can see now, that adminhtml cookie dissapears from TxHeader, but frontend cookie remains. Openning another browser and visiting the site as new user increases only cache_miss number in varnishstat. –  Tomas Mar 8 '12 at 14:00
    
I can see now improved htirate ratio and pinging the site from pingdom is raising cache_hit numbers. Loading time is 1.5s in average. Do you think its a log time for magento? Should it be under 1 second? –  Tomas Mar 8 '12 at 14:22
    
I am not sure with Magento, but on average I think 1.5s is a quite high loadtime. I'm glad the answer could get you further. –  pkhamre Mar 9 '12 at 9:22
show 4 more comments

It sounds awfully like your VCLs are wrong as your cache isn't consistent across multiple computers.

I'm not sure what VCLs you are using, but I would suggest reading this

http://www.sonassihosting.com/blog/magento-performance/magento-performance-optimization-with-varnish-cache-4/

There are working and tested VCLs for Magento 1.4 and Varnish 2 that provide the results you are looking there

share|improve this answer
    
Thank you for your answer. Unfortunatelly, this code is outdated. New Varnish uses different code for its configuration file VCL. –  Tomas Mar 13 '12 at 13:26
    
Correct, it is for Varnish 2.x - but is a known working configuration that we use on several extremely high traffic sites. –  sonassi Mar 13 '12 at 18:00
    
Thank you for an update. I use Magento 1.6.1.0 and Varnish 3.0.2. If you know some good working config for this set-up, please, let me know! ;) –  Tomas Mar 15 '12 at 16:08
    
Well, we don't use Varnish 3 in production, as our Varnish 2 VCLs work extremely well. My suggestion would be not to use Varnish 3 unless a) you know how to write the VCLs accurately yourself, or b) you have an explicit reason to do so (eg. ESI) –  sonassi Mar 15 '12 at 17:13
    
Thank you for an explanation. We get it to work quite well now. We also installed APC and Memcached, and now it seems to load pretty well (it could be always better of course:)). Loading time is now in average 900-950ms. Do you think it's pretty good loading speed in average? Thank you! –  Tomas Mar 19 '12 at 8:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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