I'm using fastcgi-cache full page caching and using php for geoip_country_code, I just used a vpn and connected to another country and I realized the page is being cached.
I followed this: https://www.howtoforge.com/using-geoip-with-nginx-on-ubuntu-12.04 but it's only php examples, and I can't find any javascript examples. I'm calling the variables from fastcgi_params, that's only accessible by php right?
My question is: How to stop this code from caching, I think javascript would not cache it then right?
<?php
$geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
$geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
switch ($geoip_country_code) {
case "US":
echo "USA";
break;
case "UK":
case "IE":
case "AU":
echo "AU";
break;
default:
echo "default";
}
?>
If so how to make this php as javascript?
So far I have tried:
<?php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
$geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
$geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
//etc..
and it still caches the php code, which is why I'm asking how to do it in javascript?
So far I got:
<script type="text/javascript">
document.write("Entering switch block<br />");
var $geoip_country_code = getenv(GEOIP_COUNTRY_CODE);
var $geoip_country_name = getenv(GEOIP_COUNTRY_NAME);
switch ($geoip_country_code) {
case "US":
text = "USA";
break;
case "UK":
case "IE":
case 'AU': document.write("Good job<br />");
break;
default:
document.write("Good job<br />");
}
</script>
But it's not working, my javascript is limited, what am I doing wrong?