Quantcast
Viewing all articles
Browse latest Browse all 19285

mathiasppc on "[Plugin: W3 Total Cache] Problems with Page Cache and Geotargeting"

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?

http://wordpress.org/extend/plugins/w3-total-cache/


Viewing all articles
Browse latest Browse all 19285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>