Clear nginx cache on multiple servers?


#1

Hi, I have ee running on multiple servers with a loadbalancer in front and separate db server. I have w3total cache setup to clear object cache and memcached using internal ip’s and it works great. see screenshot


When I click to clear the nginx cache it only clears the cache on the server I’m connected too. Is there a way to use internal ip’s to clear multiple servers at the same time?

Thanks in advance.


#2

I also have the servers setup to cluster using phpMemcachedAdmin


#3

Hi aronwp,
You can use this script to clear cache on multiple servers at a time


#4

Thanks Harshad, Can you tell me how to use this script? I’m a little confused. Where would I add the server ip addresses? Do I turn this into a WordPress plugin?

Thanks for the reply

Aron


#5

Hi Aron,

above script is already part of easyengine. You just need to execute that file like https://example.com:22222/cache/nginx/clean.php.
So to clean all servers nginx cache at a time, you can develope a simple script executing these scripts at a time.


#6

Hi, Just wan’t to confirm. If I call that script it will clear the nginx cache of the domain in the url or all domains on all the servers?

What I am really trying to do is when one of the admins from the domain clicks the clear cache button within WordPress all the servers clear the cache for that specific domain but not the others. Since the admin of the site will be clearing the cache I’m not sure how I can have the different admins for the different domains execute the script. Especially since they are not sys admins.

Also since using the domain and not the ip address how will the script know to clear all servers instead of the one the load balancer routed the url to.

Thanks for your replies
Aron


#7

Hi aronwp,

Suppose you have server1, server2, server3.
when you call clean.php on server1 it will clear cache for all domains on server1.

We do not have feature to clear cache for single domain yet.


#8

Hello @aronwp

I hope your query is resolved. I am closing this support ticket for now.

Feel free to create a new support ticket if you have any queries further. :slight_smile:


#9