magneto-varnish
magneto-varnish copied to clipboard
Clear Varnish Cache when using shared Varnish server
When using one Varnish server for multiple domains / magento shops, using the clear Varnish cache within one shop will also clear cache for other shops on the Varnish server. Even when shops are on differend backend servers.
Using magento 1.6.1 and Varnish 2.1
I've attempted to solve this in my branch:
https://github.com/allardhoeve/magneto-varnish
Please pull from there if you want and give it a try.
Seems to work for individual URL purges when updating articles or pages, but when using cache management for full store cache flush it seems there's still no host header sent.
Product update: 13 RxRequest c PURGE 13 RxURL c /electronics/cell-phones/htc-touch-diamond.html 13 RxProtocol c HTTP/1.1 13 RxHeader c Accept: / 13 RxHeader c Host: demo.lab.*****.nl 13 VCL_call c recv 13 VCL_acl c MATCH trusted 172.16.143.47 0 Debug - "VCL_error(200, PURGE)"
Store cache flush: 13 RxRequest c PURGE 13 RxURL c /.* 13 RxProtocol c HTTP/1.1 13 RxHeader c Host: 172.16.143.76 13 RxHeader c Accept: / 13 VCL_call c recv 13 VCL_acl c MATCH trusted 172.16.143.47 0 Debug - "VCL_error(200, PURGE)"
172.16.143.76 is varnish cluster virtual ip so whole cache is flushed.
Yes, I haven't coded that part yet. I have no idea how to list all the stores in the backend. But I'm sure I'll get around to it.
At least the categories, etc. are flushed now. The rest should be relatively easy.
Try again with the latest commit. It sends headers now. I haven't tested extensively, but I see them in varnishlog. I need to optimize the code though.
Help appreciated.
The headers indeed appear in varnishlog, but it still seems to clear everything here on my lab setup.
This is a VCL issue. Match req.http.host in your PURGE regexp like so:
purge("req.url ~ " + req.url + " && req.http.host == " + req.http.host);
Haven't tested, because I'm om Varnish 3.0 and you seem to be on Varnish 2.x. Fiddle with the config a bit if you will.
Indeed a VCL issue, seems i somehow went back to an older VCL which didn't match the req.http.host
purge("req.url ~ " req.url " && req.http.host == " req.http.host); works
Thanks.
allardhoeve, your branch gives a 404. Would like to see your solution. Maybe i can use it with the problem i'v got.
Shared varnish servers with multidomain shops and serveraliases.
thx,
Coen
Hey Coen,
Yeah, my branch moved :)
I'll try and reupload the branch.
Best,
Allard