BenjaminAdams / wp-redis-cache

Cache Wordpress faster
157 stars 37 forks source link

Conflict with CloudFlare Plugin? #35

Closed TechRemarker closed 9 years ago

TechRemarker commented 9 years ago

When using CloudFlare DNS it's highly recommended to use the official CloudFlare WordPress plugin to assure CloudFlare uses proper IP addresses. However, if I enable that plugin the wp-redis-cache plugin does not work because the plugin thinks $_SERVER['REMOTE_ADDR'] is my computer's local IP rather than the server IP. Any ideas on how to work around that issue (assuming it's not unique to my setup)?

BenjaminAdams commented 9 years ago

Going to have to hack the plugin so it looks for the cloudflares forwaded IP

on https://github.com/BenjaminAdams/wp-redis-cache/blob/master/index-wp-redis.php#L23

&& $_SERVER['REMOTE_ADDR'] != $websiteIp);

change to

&& $_SERVER['X-Forwarded-For'] != $websiteIp);
TechRemarker commented 9 years ago

Damn, you are fast and awesome. Looked closer and actually I was wrong it seems as whether plugin is enabled or not, my homepage the cached worked but on any interior page the cache didn't work because as mentioned above the remote_addr shows as my local ip. But emptied redis cache and homepage cache also not working now (with or without cloudflare enabled). So this may in fact not be a cloudflare issue. I'll do more internal testing and if can't figure it out will create a new issue here unless you have any ideas. Thanks Ben!

TechRemarker commented 9 years ago

After much hunting realized pages weren't caching because I had logged into the WordPress site. After logging out or using incognito mode works perfectly. Should have figured it was something simple.

BenjaminAdams commented 9 years ago

awesome =)