WebPagetest Forums
Fastest method to identify user agent - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: Web Performance (/forumdisplay.php?fid=3)
+--- Forum: Optimization Discussions (/forumdisplay.php?fid=5)
+--- Thread: Fastest method to identify user agent (/showthread.php?tid=12167)



Fastest method to identify user agent - silverman - 04-10-2013 03:54 AM

What is the fastest method to find out which browser a vistor is using? I need to do a redirect from my website to another website and this redirect should be different depending on the visitors user agent.

Thank you!


RE: Fastest method to identify user agent - pmeenan - 04-16-2013 03:25 AM

A user agent match in your web server config is going to be the fastest way to do it. That way the server can do the redirect without having to start up a cgi process of any kind (how you do it differes depending on the server - apache, nginx, etc).

It also somewhat depends on how complicated you need to be in detecting the browser. Something like "Mobile" vs "Desktop" can be a crazy exercise to do and there are entire databases that are devoted to maintaining the UA strings for the devices.


RE: Fastest method to identify user agent - silverman - 04-16-2013 11:51 PM

@pmeenan

Thank you for your answer! Does that mean we should use mod_rewrite to do the redirect based on the user agent on Apache?


RE: Fastest method to identify user agent - pmeenan - 04-17-2013 12:30 AM

Yes, if you are on apache and you can define your user agents succintly enough, mod_rewrite would be your fastest way to do the redirects.


RE: Fastest method to identify user agent - silverman - 04-17-2013 09:24 PM

Thank you for your help, @pmeenan!