Redis_cache with geoip target country


#1

I really appreciate anyone who can help me to solve this problem because I am still newbie to easyengine wordpress nginx.

I setup my wordpress site with hhvm + redis_cache. I try to use CloudFlare ip to detect visitor country and display specific certain content to visitors from country such as US. It works sometimes and afterthat it is not working as It always cache the content of the prior user if i didn’t purge the cache.

Example of my wordpress theme function.php codes :

// Display content to US visitor Only function getCountry($atts, $content = null) { $country = $_SERVER[“HTTP_CF_IPCOUNTRY”]; if($country == ‘US’) return $content; else return ‘’; }

add_shortcode(‘visitorCountry’, ‘getCountry’);

Example of usage in any post/page : [visitorCountry]You’re from United State[/visitorCountry]

So i can simply use this shortcode to display content to US visitor.

I had saw the fastcgi_cache below but don’t have redis_cache ones :

How, Where can i change and put this fastcgi_cache_key “$scheme$request_method$host$request_uri$cookie_country” to the redis_cache ones? How to set the $cookie_country ? Is it i can set it as $geoip_country_code to get the visitors country as well ? Thank you.


#2