Hello,
I am fairly new to ModX and I'm running into some caching issues. I created a snippet to determine if the user is coming from a mobile device or a desktop:
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if(preg_match('/iPhone|Android|Blackberry/i', $agent)){
return "You're using a mobile device. <br/>
QUERY_STRING: " . $_SERVER['QUERY_STRING'] . "<br/>
HTTP_USER_AGENT: " . $agent ."<br/>
REQUEST_URI: " . $_SERVER['REQUEST_URI'];
}
else
{
return "You're NOT using a mobile device. <br/>
QUERY_STRING: " . $_SERVER['QUERY_STRING'] . "<br/>
HTTP_USER_AGENT: " . $agent ."<br/>
REQUEST_URI: " . $_SERVER['REQUEST_URI'];
}
?>
It works perfectly on the first browser/device I tried, but after that any browser/device I use will display the results of the first one until I clear the site cache.
For example: If I go to my site using my Razr it will display that I'm using a mobile device, but if I then use chrome on my computer it would also say it is a mobile device. If I clear the cache and go to my computer it will say chrome, but then when I go to my razr it will also say I'm using chrome.
I tried changing a few settings under "caching" with no luck. Has anyone ran into a similar issue? I'm not sure if it is a simple setting or something in my .htaccess file or what. I tried creating this as a static page I did not see these issues so I know it is not an issue with my host/server.
Thanks,
Chris