Support » 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 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mathiasppc

    (@mathiasppc)

    Oh, and here`s the site (now with page cache disabled): http://energyinformative.org

    I have exactly the same issue,

    It seems very little support is available for cache by geoip in wordpress.

    I would love to use W3 Total cache but it seems from what I read so far that SuperCache may well be better for your instance check under:
    How do I make certain parts of the page stay dynamic? on the FAQ page

    Not sure if a similar option exists for W3 Cache from what I read so far its seems that w3 cache lets you deselect a page from caching but thats about all.

    Unfortunately for me, I want to be able to cache on a way more advanced level including a cache for mobile, language and country.

    Something like this super cache with geo-ip targeting with some more options added would be perfect.

    I’m still in my early stages of research into caching by Geoip but I read those options existed and thought it may be of help to you.

    daniel.z

    (@danielz-1)

    Hey mathiasppc,
    i’ve had the same issue as you did and i’ve described the tweak i did to W3TC here.
    Hope it helps.

    Thanks Daniel,

    Your method works perfectly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Problems with Page Cache and Geotargeting’ is closed to new replies.