简体   繁体   English

移动检测高流量站点

[英]mobile detection high traffic site

i have a high traffic website (1+ Millions visitors per day) and i need to detect their user agent. 我有一个高流量的网站(每天1百万以上的访问者),我需要检测他们的用户代理。 i have a list over 1000 mobile devices. 我有一个超过1000个移动设备的列表。

i run memcache to output dynamic content based on what page they access and params they put eg: 我运行memcache根据他们访问的页面和他们放置的参数输出动态内容,例如:

/document/page/1?textsize=large /文件/页/ 1?TEXTSIZE =大

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://www.mobile-phone-specs.com/user-agent-browser/0/

http://detectmobilebrowsers.mobi/ http://detectmobilebrowsers.mobi/

http://detectmobilebrowsers.com/ 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. 编辑:我需要知道我的PHP代码是否是移动或不是浏览器。

how can i make this check to run faster? 我怎样才能使这项检查更快地运行?

Use all the answer above. 使用上面的所有答案。

Use the CSS to display your page correctly. 使用CSS正确显示您的页面。 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) 只是要小心css / js / images / html页面的大小,对于慢速设备,可能需要永远加载不加载图像或大js文件的页面(如旧翻盖手机,你可以看到s ** t在上面)

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. 在您的PHP上使用逻辑脚本来找出您获得的最多浏览器然后将其保存在会话中,这样您就不必每次都检查它。

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. 在您的情况下,我会通过响应式设计和css策略将移动检测外包给客户端......从处理流量负载的服务器中解除所有开销。

CSS3 Media Queries to override styles for Mobile specificity is a very popular approach these days. 如今,CSS3媒体查询覆盖移动特性的样式是一种非常流行的方法。

http://webdesignerwall.com/tutorials/css3-media-queries http://webdesignerwall.com/tutorials/css3-media-queries

Example site - Start shrinking your browser down to see it in action. 示例站点 - 开始缩小浏览器以查看其运行情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM