0

We have successfully configured varnish in our magento website, it's working great. But the problem is varnish is not purging when we clear the cache either via admin panel or ssh command. We restart varnish server every time. We have also configured CDN (It may be reason for this cache issue). We have tried to set http_cache_hosts using the command

bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:6081

Also tried with ports 8080,6082

In our .vcl file

acl purge {
    "xx.xx.xxx.xxx";
}

Above configurations is not at all working. We are missing something to make it work. Can anyone help on this?

0

It is because of we missed to add our server ip address to the access list of varnish server. We can add our ip address also in the Access List field of Varnish configuration. If you use your own default.vcl in varnish server, it is enough to add magento server ip like below in default.vcl

acl purge {
    "xx.xx.xxx.xxx"; //Varnish server IP
    "yy.yy.yyy.yyy"; //Website server IP
}

Also make sure you have added varnish server ip in http_cache_hosts using below command

bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:80
  • Hiello sibhi how do we know varnish server ip and wbsite server ip? – Nagaraju K Mar 7 '19 at 8:45
0

1- check varnish port using :

sudo netstat -ltnp 

in my case it's port 80 enter image description here

2-Update cache host using

php bin/magento setup:config:set --http-cache-hosts=xx.xx.xxx.xxx:80

here i'm using port 80 ( varnish cache port )

3- check your vcl settings ( i'm using ubuntu under: /etc/varnish/default.vcl )

backend default {
    .host = "XX.XX.XX.XX";//here replace localhost with your ip
    ....

acl purge {
    "XX.XX.XX.XX";//here replace localhost with your ip
   }

4-Now check if purge request received using

varnishlog -g request -q 'ReqMethod eq "PURGE"'

to send PURGE request go to the Admin, click SYSTEM > Tools > Cache Management, then click Flush Magento Cache at the top of the page.

or

using cmd

php bin/magento cache:flush 

Dont' forget to restart varnish after changes :

service varnish restart

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.