Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get_browser slowing down page load, any alternative?

I have used PHP's get_browser function for quite some time now and have never really noticed any lag on any of my websites. However, recently I noticed that one of my sites was taking a second or so more to load at the server end than it should take. I commented out the get_browser function and the page loaded instantly.

Could this be to do with my server or is the get_browser function known to be slow? The website is the only website I have that is running on a windows server, could this be the issue? Or could this be to do with my browscap.ini file (this is updated everyday from http://browsers.garykeith.com)?

If there is nothing I can do to speed up the get_browser function, are there any alternatives to it? I need to reliably collect the following information about the browser:

  1. What browser it is, i.e. Chrome, IE, Safari etc
  2. What version it is (in full), i.e 10.1 etc
  3. Whether it is a crawler or a bot

I am not aware of any other methods of gathering this information from the user agent, would it be better to use javascript (I would rather not as I need the values server side)?

like image 487
Ben Carey Avatar asked Dec 01 '25 09:12

Ben Carey


1 Answers

I also experiences about a 5s delay when using get_browser so i also looked for another solution.

What works great and will surely be up to date for a long time is a lib in piwik:

  • Piwik Device Detector
like image 104
ThaDafinser Avatar answered Dec 03 '25 22:12

ThaDafinser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!