What Is a User-Agent
User-Agent Guide
When a web browser or app sends a request to a server, it includes information in the HTTP header about what program it is. This is the User-Agent (UA) header. From this value, the server infers what browser, operating system, and device the client that sent the request is.
Where It's Used
The User-Agent is used for several purposes. The most common ones are as follows.
- Responsive branching that serves a layout suited to mobile or desktop
- Compatibility handling that works around bugs in specific browsers
- Identifying search engine bots to apply crawling policies
- Tallying browser market share in access statistics and analytics
Why Is the Format So Complicated
Today most UAs start with Mozilla/5.0. This is the result of a practice from the 1990s browser wars, where browsers imitated each other's names to appear to support each other's features, and it stuck. So the actual browser name has to be checked in tokens further back in the string, such as Chrome/, Firefox/, or Safari/.
The User-Agent is a value the client reports about itself, so it can be changed at any time. For that reason it should never be the sole basis for a security decision.
Summary
The User-Agent is the client's self-introduction. Remember that it's convenient but unreliable information, and it's best to use it for reference.