Welcome Guest, you are in: Login

MUST Creative Engineering Laboratory

RSS RSS

Navigation



Technical Doc



Search the wiki
»

MUST Corp.

MUST Corp.

www.must.or.kr

 Microsoft CERTIFIED Partner Software Development, Web Development, Data Platform

 Microsoft Small Business Specialist

MCSD

Microsoft Certified IT Professional

Microsoft Certified Professional Developer

Understanding user-agent strings

RSS
Modified on 2013/01/31 20:30 by Administrator Categorized as OS
http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx

Introduction

When you visit a webpage, your browser sends the user-agent string to the server hosting the site that you are visiting. This string indicates which browser you're using, its version number, and details about your system, such as operating system and version. The web server can use this information to provide content that is tailored for your specific browser.

Because certain non-Microsoft sites add details to the user-agent string, it's important to understand the user-agent string. Here we'll explain the user-agent string, list the values from recent Internet Explorer versions, and document registry keys that modify the user-agent string.

Understanding the user-agent string

When you request a webpage, your browser sends a number of headers to the server hosting the site that you're visiting, as shown here.

GET / HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Host: microsoft.com

These headers occur during a negotiation process that helps the browser and the hosting server determine the best way to provide the requested information. The user-agent header identifies the application requesting the information from the server, typically a browser. This identification string is called the user-agent string and contains tokens that provide specific details about the program making the request. Tokens vary among programs; the tokens in the Internet Explorer user-agent string describe the browser, the operating system, and the current browser mode.

This table describes the tokens in a user-agent string shown in the example.

TokenDescription
Mozilla/5.0Application name and version. For historical reasons, Internet Explorer identifies itself as a Mozilla browser.
compatibleCompatibility flag token. It indicates that Internet Explorer is compatible with a set of common features.
MSIE 9.0The Version token identifies the browser and contains the version number, as reported by the current browser mode. The example value indicates Windows Internet Explorer 9.
Windows NT 6.1The Platform token identifies the operating system and version. The example token indicates Windows 7.
Trident/5.0The Trident token identifies the version of MSHTML (Trident) and can be used to determine whether or not the webpage is displayed in Compatibility View.

 

In the example, Internet Explorer is the user agent. However, other programs also provide user-agent strings when contacting servers over the Internet. For example, the Windows RSS Platform provides the following user-agent header when requesting RSS data.

Windows-RSS-Platform/2.0 (MSIE 9.0; Windows NT 6.1)

Like the user-agent string for Internet Explorer, this user-agent header provides details about your system.

Alternate tokens can appear in the user-agent string for a number of reasons; usually, they identify optional features installed on your system. For example, an SV1 token appears in the user-agent string of a Windows XP user who has installed Windows XP Service Pack 2 (SP2). It's also important to note that certain non-Microsoft parties modify the user-agent string for their own purposes.

Internet Explorer 9 treats alternate tokens differently than earlier versions of the browser. For more info, see User-Agent Registry Keys.

Note  To protect your privacy, periodically review your user-agent string and verify its contents.

For info about other headers communicated to web servers, see RFC2616, Section 14: Header Field Definitions.

Viewing the user-agent string

Applications can use the userAgent property of the navigator object to determine the user-agent string.

You can use this information to view the user-agent string. To do so, type the following into the address bar of your browser.

javascript:alert(navigator.userAgent)

This code example is case sensitive.

When you do this, a dialog box displays your user-agent string.

Tip:  If you're using a recent version of Windows, you can copy your user-agent string to the Clipboard by pressingCtrl+C before you close the dialog box.

For best results, user-agent strings should not be longer than 256 characters.

Internet Explorer user-agent tokens

This section summarizes the tokens used by recent versions of Internet Explorer, which places three tokens in the user-agent string by default.

  1. Version tokens
  2. Platform tokens
  3. Feature tokens
  4. Trident token

Version tokens

In general, version tokens begin with MSIE and are followed by the version number of the browser. Many pre-release versions append the letter "b" to the version number.

Beginning with Windows Internet Explorer 8, the version token reported in the user-agent string might not reflect the actual version of the browser. If Compatibility View is enabled for a webpage or the browser mode is set to an earlier version, the version token reports the earlier version.

For example, if you're using Internet Explorer 9 to view a webpage in Compatibility View, the version token is, by default, MSIE 7.0.

This means that the version token represents the way Internet Explorer is presenting itself to the web server. As of Internet Explorer 8, theTrident token more accurately represents the version of the browser.

This table lists the version tokens used in recent versions of Internet Explorer.

Version tokenDescription
MSIE 10.0Internet Explorer 10
MSIE 9.0Internet Explorer 9
MSIE 8.0Internet Explorer 8 or IE8 Compatibility View/Browser Mode
MSIE 7.0Windows Internet Explorer 7 or IE7 Compatibility View/Browser Mode
MSIE 6.0Microsoft Internet Explorer 6

 

Platform Tokens

Platform tokens describe your operating system. The following table lists Internet Explorer platform tokens for the last several versions of Windows.

Platform tokenDescription
Windows NT 6.2Windows 8
Windows NT 6.1Windows 7
Windows NT 6.0Windows Vista
Windows NT 5.2Windows Server 2003; Windows XP x64 Edition
Windows NT 5.1Windows XP
Windows NT 5.01Windows 2000, Service Pack 1 (SP1)
Windows NT 5.0Windows 2000
Windows NT 4.0Microsoft Windows NT 4.0
Windows 98; Win 9x 4.90Windows Millennium Edition (Windows Me)
Windows 98Windows 98
Windows 95Windows 95
Windows CEWindows CE

 

Feature tokens

Certain optional components can also modify the user-agent string; this next table shows common ones. Be aware that many other applications also modify the user-agent string. Because of this, a comprehensive list is not possible. If you find additional tokens in your user-agent string, investigate them in more detail.

TokenDescription
.NET CLR.NET Framework common language run time, followed by the version number.
SV1Internet Explorer 6 with enhanced security features (Windows XP SP2 and Windows Server 2003 only).
Tablet PCTablet services are installed; number indicates the version number.
Win64; IA64System has a 64-bit processor (Intel).
Win64; x64System has a 64-bit processor (AMD).
WOW64A 32-bit version of Internet Explorer is running on a 64-bit processor.

 

Trident token

When the F12 developer tools are used to change the browser mode of Internet Explorer, the version token of the user-agent string is modified to appear so that the browser appears to be an earlier version. This is done to allow browser specific content to be served to Internet Explorer and is usually necessary only when websites have not been updated to reflect current versions of the browser.

When this happens, a Trident token is added to the user-agent string. This token includes a version number that enables you to identify the version of the browser, regardless of the current browser mode.

TokenDescription
Trident/6.0Internet Explorer 10
Trident/5.0Internet Explorer 9
Trident/4.0Internet Explorer 8

 

In general, public websites should rely on feature detection, rather than browser detection, in order to design their sites for browsers that don't support the features used by the website. For more info, see Detecting Internet Explorer More Effectively.

Sites that rely on user-agent strings to generate visitation statistics should update their algorithms to account for the Trident token; otherwise, visitation metrics might not accurately reflect the true composition of browser usage.

User-agent registry keys

When you install certain third-party programs or Windows components, such as the Microsoft .NET Framework or Windows XP SP2, feature tokens are added to the user-agent string.

This is done by adding tokens to the following registry keys.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Windows
            CurrentVersion
               Internet Settings
                  User Agent
                     Pre Platform
                        Token = Value
                     Post Platform
                        Token = Value

The Pre-Platform and Post-Platform keys contain values whose names appear before and after the Platform token, respectively. For example, if a string value is added to the Post-Platform key, the name appears after the platform token in the user-agent string. Multiple tokens added to either key appear in an unpredictable order.

Earlier versions of Internet Explorer included feature tokens defined using the Pre-Platform and Post-Platform keys part of the user-agent string during the HTTP negotiation process. Over time, this lead to overly long user-agent strings, which in turn created problems for certain web servers. Problems usually appeared when user-agent strings were longer than 256 characters. As of Internet Explorer 9, the user-agent string no longer includes feature tokens during HTTP negotiation. Feature tokens are included in the value returned by theuserAgent property of the navigator object. Applications that rely on the earlier behavior should be modified accordingly.

Note  The user-agent string should not be used to indicate the presence of optional software or features. Custom version vectors, which can be detected using conditional comments, provide a more appropriate mechanism.

You can also override certain tokens of the user-agent string by adding values to the following registry key.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Windows
            CurrentVersion
               Internet Settings
                  5.0
                     User Agent
                        (default) = "Mozilla/4.0"
                        Compatible = "compatible"
                        Platform = "Windows NT 5.1"
                        Version = "MSIE 6.0"
                        Pre Platform
                           Token = Value
                        Post Platform
                           Token = Value

The default value of the User Agent key replaces the application name and application version tokens reported in the user-agent string. Be aware that the first seven characters are used for the application name, and the remaining characters specify the application version token.

The Compatible, Platform, and Version values replace the corresponding tokens in the user-agent string.

Additional tokens can be added to the user-agent string by using the Registry Editor to create new string values under the Pre-Platform key or Post-Platform key. The value name should be the complete token; the value data is ignored. Tokens added to the Pre-Platform key appear before the platform token in the final user-agent string. Tokens added to the Post-Platform key appear after the platform token in the final user-agent string. Multiple tokens in either the Pre-Platform key or Post-Platform key are displayed in an unpredictable order.


MUST Creative Engineering Laboratory

ImageImage Image Image

Image Image Image Image Image Image Image

Copyright © 2010 MUST Corp. All rights reserved. must@must.or.kr
This Program is released under the GNU General Public License v2. View the GNU General Public License v2 or visit the GNU website.