i have a high traffic website (1+ Millions visitors per day) and i need to detect their user agent. i have a list over 1000 mobile devices.
i run memcache to output dynamic content based on what page they access and params they put eg:
/document/page/1?textsize=large
and i don't have static pages nor i cant use sub-domains.
i found different scripts that check user agent:
http://www.mobile-phone-specs.com/user-agent-browser/0/
http://detectmobilebrowsers.mobi/
http://detectmobilebrowsers.com/
my question is, performing these check every time a page load will make my site slow with the traffic i get
edit: i need to know in my php code if it's a mobile or not browser.
how can i make this check to run faster?
Use all the answer above.
Use the CSS to display your page correctly. since its only display let the browser loads deal with it. just be careful of how big the css/js/images/html pages are, for slow devices it might take forever to load a page that does not load images or big js files (like old flip phone where you can see s**t on it)
on your php use a logic script to find out the most browser you get then save it in session so you dont have to check it everytime.
something like:
if(!$_SESSION['var']) {
if(stripos($_SERVER['HTTP_USER_AGENT'], 'iphone') !== FALSE) {
$_SESSION['var'] = 'iphone';
}
// etc...
// your else case can be desktop or default.
}
In your case, I would outsource the mobile detection to the client side with responsive designs and css strategies... lifting all overhead from your server that is dealing with the traffic load.
CSS3 Media Queries to override styles for Mobile specificity is a very popular approach these days.
http://webdesignerwall.com/tutorials/css3-media-queries
Example site - Start shrinking your browser down to see it in action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With