Great plugin btw!
I`m unable to use page cache with my geotargeting script based on the MaxMind GeoIP database (http://www.maxmind.com/en/geolocation_landing).
Most of the time it works as it should, but sometimes, around 50% of the page loads show that I`m from a different country than what I actually am. Everything works as it should without page cache enabled.
Here`s the script:
Header:
<?php
// Start session
add_action('init', function() {
session_start();
require_once("/home/energy/public_html/geoip.inc");
$gi = geoip_open("/home/energy/public_html/GeoIP.dat",GEOIP_STANDARD);
$_SESSION['country_code']= geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);
});
And here`s the code I use to select ads based on country code.
<?php
//Retrieve session data
$country_code = $_SESSION['country_code'];
if($country_code == 'US' || $country_code == 'CA' || $country_code == false)
{
echo '[adrotate group="5"]';
}
else
{
echo '[adrotate group="3"]';
}
?>
If anyone knows what might be the issue, please shout out?
Also how important is having page cache enabled for speed?