Support

Find answers, guides, and tutorials to supercharge your content delivery.

User Agent String

Updated on October 4, 2018
User Agent String

What is a user agent string?

A user agent is a piece of software that acts on behalf of a user, such as a web browser. A user agent string however is sent as an HTTP request header by the browser and identifies which operating system is being used, the browser version, and other information which is provided to the web server.

The naming conventions for user agent strings can sometimes be confusing as they often contain tokens that may not have an obvious meaning. However, these strings contain important information that will allow a particular website's web server to deliver content that is most compatible with your web browser, browser version, etc.

User agent tokens

Within user agent strings there can exist many tokens. These tokens are what provide specific detail to the web server so that it can respond appropriately. The section below describes a few token categories and their purpose.

Version tokens

Version tokens, as the name implies, display the version of a particular browser. The following list displays examples for three various popular web browsers.

TokenDescription
Chrome/41.0.2228.0Chrome web browser running on version 41.0.2228.0
Firefox/40.1Firefox web browser running on version 40.1
MSIE11Internet Explorer web browser running on version 11

Platform tokens

Platform token are used to help the web server identify which operating system is being used. The following are token examples of various platforms.

TokenDescription
Intel Mac OS X 10_11_2Macintosh OS X version 10_11_2 running on Intel CPU
Linux x86_64Linux running on Intel CPU and 64-bit processor
Windows NT 6.3Windows 8.1

Other tokens

There are many other tokens that exist that may also be included in the user agent string. Although the list is quite large, here are a few popular other tokens to mention.

TokenDescription
Tablet PCTablet services are installed. This token is also accompanied by a version number
AppleWebKitProvides a set of core classes to display web content in windows
Like GeckoMozilla-based rendering engine
KHTMLKonquerer-based rendering engine

User agent string example

User agent strings can come in many different forms depending on the combinations of software being used. The user agent string that your system sends to a web server as a request header can be seen within Chrome DevTools by navigating to the Network tabs, selecting an asset, and finding the User-Agent request Header.

In the above screenshot, the resulting user agent string is:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.80 Safari/537.36

These components can be broken down into the following:

  • Mozilla: In modern browsers this is irrelevant and only used for historical reasons.
  • 5.0: Mozilla version
  • Macintosh: Platform
  • Intel Mac OS X 10_11_2: The operating system is OS X version 10_11_2 and running on Intel CPU
  • AppleWebKit/537.36: WebKit build 537.36 that helps display web content in windows
  • KHTML, like Gecko: HTML layout engine developed by the KDE project and similar to the Gecko engine
  • Chrome/47.0.2526.80: Chrome web browser, version 47.0.2526.80
  • Safari/537.36: Based on Safari build 537.36

User agent sniffing

User agent sniffing was previously used by web developers who wanted to show different content to different browsers based on the user agent. Today, this is not a recommended practice. Rather, today it is recommended to develop a website or application that is usable regardless of the browser that makes a request for the content.

Where user agent sniffing or device-based detection is more prominently used is mobile devices. By today's standards, it is advised to build a responsive website that is resizable and functions similarly regardless of whether users are accessing it via mobile or desktop. However, not all websites these days are responsive. Certain website owners have legacy systems and reformating their entire site would take a lot of time and money. Therefore, separate mobile versions of the web page are created to deliver content to these users. Although there are other ways to determine a device type, user agent is still used in many cases to achieve this. Therefore, KeyCDN has a feature called device-based caching which allows you to cache different assets based on the user agent detected.

User agent spoofing

Something to be aware of in regards to user agents is that in certain cases browsers actually spoof their user agent in order to access content that was otherwise inaccessible. For example, if a web developer create a more feature-rich version of their website or application with the intent of browser A accessing that content but not browser B, browser B can sometimes spoof their user agent to be able to access such features. For example, the Android browser identifies itself as Safari (among other things) in order to aid compatibility.

Furthermore, other HTTP client programs and spam bots / web scrapers often use fake user agents. This means that the user agent statistics you collect either via Google Analytics or some other RUM service may not actually be 100% correct.

Summary

The user agent string is an important aspect of the web as it identifies many various software components and delivers them to the web server for optimal HTTP responses. Without this identification, web servers would not be aware of compatibility issues that may occur with certain types of software and what should be done to avoid them.

When analyzing the KeyCDN logs, there is also the ability to display the user agent string which may be beneficial for debugging purposes.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

Get started
KeyCDN uses cookies to make its website easier to use. Learn more