Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mobile detection high traffic site

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?

like image 359
aki Avatar asked Dec 14 '11 16:12

aki


2 Answers

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.
}
like image 71
eric Avatar answered Oct 04 '22 09:10

eric


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.

like image 28
jondavidjohn Avatar answered Oct 04 '22 09:10

jondavidjohn