MyBB Internal: One or more warnings occured. Please contact your administrator for assistance.
WebPagetest Forums - Fastest method to identify user agent

WebPagetest Forums

Full Version: Fastest method to identify user agent
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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.

Thank you for your answer! Does that mean we should use mod_rewrite to do the redirect based on the user agent on Apache?
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.
Thank you for your help, @pmeenan!
Reference URL's