An article takes you to understand what UA is

Recently, I am doing some UA statistics, and I just made a record. Students who need it can also learn from it.

 

1. First, what is UA?

        UA, the full name is "User Agent", which is usually translated directly into "User Agent" in Chinese, but from the perspective of its mechanism of action, it may be more appropriate to call it "browser logo" or "browser business card".

        In fact, UA is a string of specific characters sent to the web server when a browser is used to access a website. Its content usually includes "operating system and version", "CPU type", "browser and version", "browser browser rendering engine", "browser language", "browser plug-ins" and other information. Based on this string of characters, the website server can roughly determine the software and hardware environment used by the user, and then adopt different content strategies. These content policies were often used in the early days of the Internet to address compatibility issues

Take Safari on the iPad as an example, the UA it uses is the following string (the UA string may vary depending on the Safari version

Mozilla/5.0(iPad;U;CPU OS 3_2_1 like Mac OS X; en-us)AppleWebWebKit/531.21.10(KHTML, like Gecko) Mobile/7B405

The composition and description of this set of strings are as follows:

 

 2. The history of UA

1. The Birth of the Browser

        After the birth of the Internet, British computer scientist Berners-Lee first pointed out the feasibility of grafting hypertext to the Internet. In 1990, Berners-Lee wrote the first web page to implement his idea on a NeXT workstation. In this way, the World Wide Web (WorldWideWeb) was born, and Berners-Lee is therefore known as the father of the Web.

That same year, Berners-Lee also produced two of the most fundamental tools needed for the World Wide Web -- the first web server and the first web browser. Berners-Lee named the browser "Nexus." In this sense, Berners-Lee is also the father of the browser. However, the Nexus browser can only display text and cannot display pictures, which leaves market space for the emergence of other browsers and also plants the seeds for the emergence of UA.

2. The birth of UA

        Due to the inadequacies of the Nexus browser, it is an urgent need for users to realize the function of browsing pictures. On January 23, 1993, the National Center for Supercomputing Applications, referred to as NCSA, released the first graphical browser in the history of the Internet - Mosaic (Mosaic). The Mosaic browser can display text and pictures at the same time, making the browser interesting and popular.

        In order to take advantage of the Mosaic browser and allow the web server to push content with pictures to the Mosaic browser, it is necessary for the web server to distinguish the Nexus browser from the Mosaic browser. The practice of the NCSA organization is to first send a specific character string to the server when accessing the web server: "Mosaic/2.0 (Windows 3.1)" as the identification of its own browser. Since then UA was born.

At this time, UA was indeed innocent, and only indicated what browser and system he was on, as well as the version numbers of the two.

3. The birth of the Mozilla browser

        In 1994, Marc Andreessen, the core member of Mosaic browser research and development, and Jim.H.Clark, the inventor of the geometry generator, formed a company to release another browser, named Mozilla, Chinese Name Mothra. Since then, the great Mozilla browser was born.

        In December 1994, Mozilla changed its name to Netscape, the Netscape browser, but Netscape still identified itself as Mozilla: "Mozilla/1.0 (Win3.1)". Since frame technology became popular in web development at that time, Netscape supported frame technology, while other browsers either did not support it or did not support it well. Netscape soon became the most popular browser with the highest market share at that time. At the same time, webmasters began to use detection technology and differentiated pages in server settings, sending pages with frames to Netscape browsers and pages without frames to non-Netscape browsers.

        Mozilla holds a pivotal place in browser history. Not only has it become as popular as it was after its birth, it has become the object of many browsers competing to learn. And in the subsequent history, although it went through several twists and turns, changed its name many times, and faced the test of life and death repeatedly, Mozilla was always reborn like a phoenix, and its "descendants" always had a place in the market. Even today, Mozilla as a browser itself has disappeared from the market, but many browsers still label themselves as "Mozilla" in UA.

        It can be said that Netscape and subsequent Firefox browsers are the orthodox descendants of Mozilla, and it is beyond reproach to mark itself as Mozilla in UA. But soon, the "six-eared macaque" appeared, and other browsers marked themselves as Mozilla. The "instigator" of all this is Microsoft's IE browser. That year was 1995.

4. The Birth of Internet Explorer

        On August 16, 1995, Microsoft developed its own browser Internet Explorer (IE for short) that supports frame technology, and hopes to replace the Netscape browser. But Microsoft soon discovered that although the IE browser also supports frames, it often cannot receive pages containing frames. The reason is that the server of the website will first determine what browser is accessing itself when receiving the browser's access request. If the UA contains Mozilla, it will think that Mozilla (Netscape) is accessing itself, and push the framed URL to the browser. page; if Mozilla is not included in the UA, it is considered that other browsers are accessing itself, and a frame-free page is pushed to the browser.

        In order for users to receive framed pages when using IE, Microsoft began to claim that it was compatible with Mozilla, and imitated Netscape's logo, using Useragent to mark itself as "Mozilla/1.22 (compatible; MSIE 2.0; Windows 95)", So IE can also receive the page containing the frame. Since then, Useragent has become an important technology commonly used by browsers to solve compatibility and improve user experience. Since then, the IE version has been updated several times, and the UA used is more or less different from the first generation of IE, but the method of masquerading as Mozilla has not changed, and has been followed by future browsers.

        From this history, we can observe that in the short period of 6 years from 1990 to 1995, we have experienced three important histories: the birth of browsers, the emergence of UA, and the use of UA camouflage by IE browsers to solve compatibility problems. event. In the more than 20 years since 1995, UA camouflage has been widely used and has basically become an essential function of every browser.

        After more than 20 years of development, the browser industry and its UA have competed and learned from each other, and gradually formed four market forces using different kernels.

5. Gradually evolved browser branches

Gecko

 

        With the popularity of the IE browser, Netscape gradually withdrew from the stage of history, but the technical nerds in the company were unwilling to fail. On July 15, 2003, the Firefox browser was released under the name of the Mozilla Foundation (Mozilla org). The kernel, named Gecko, still uses the UA of the Mozilla browser "Mozilla/5.0(Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826"

        Due to the excellence of Gecko and the stagnation of IE, the UA detection rules have changed once again - browsers using Gecko are sent better web page codes, and other browsers do not have this treatment. So many browsers have added Gecko to their UA.

        As far as the name of Mozilla is concerned, Gecko (Firefox) has a strong root and can be called orthodox. It can be called a holy monk of the Tang Dynasty. At the same time, since eating Tang raw meat can lead to immortality, other browsers can’t wait to take a bite, at least to catch hot spots, and add Gecko to their UA, which is the origin of the character like Gecko.

KHTML/WebKit

        On October 14, 1996, when the Linux open source community developed the Konqueror browser using the KHTML kernel, it not only disguised itself as Mozilla, but also claimed to be compatible with Gecko (like Gecko). Its browser UA is "Mozilla/5.0 (compatible; Konqueror/3.2; FreeBSD) (KHTML, like Gecko)"

         KHTML/WebKit is a very good browser core, and many software vendors have developed new browser products based on this core. Konqueror, Safari, and Chrome are the first to launch, followed by QQ browser, Sogou high-speed browser, and 360 browser. It will change in seventy-two ways just like Monkey King, and it will continue to generate new browsers. It has many monkey grandchildren, and it is worthy of being a big brother in the browser industry.

         On January 7, 2003, Apple developed the Safari browser using the Webkit kernel derived from the KHTML rendering engine. For the sake of compatibility, Apple has inherited Mozilla, Gecko, and KHTML in KHTML UA. So Apple marked the UA of the Safari browser as "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/85.7 (KHTML, like Gecko) Safari/85.5". Different from IE browser, in addition to masquerading as Mozilla in the default UA of some browsers, Apple also marks its own unique browser logo Safari at the end of the UA, which is for the website to optimize for Safari after Safari becomes popular. It left space (its ipad did not make this logo), now it seems that I have to admire Apple's self-confidence and ambition. At present, many websites, especially mobile websites, have made special adaptations for Safari.

         On September 2, 2008, Google developed the Chrome browser using Webkit as a rendering engine. Like Safari, it wants to browse pages written for Safari, so it inherits Safari's UA "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2 .149.27 Safari/525.13", and add your own browser name into it, the effect received is exactly the same as Apple's approach.

Trident (IE)

        As IE browser becomes mainstream, its status seems to be more and more unshakable. Microsoft began to stop making progress. Although the IE browser has gained compatibility advantages due to its market position, its functions have stagnated, and its ease of use has become worse and worse, and it has gradually failed to keep up with the pace of the times. At this time, many function-enhanced browsers with IE (Trident kernel) as the core of the browser were born, such as Window of the World browser, Aoyou browser (old version), etc., and their UA also has an inheritance relationship with IE. To repeat them one by one, interested friends, you can check the list attached at the end of this article. IE and its Trident kernel, just like the IE browser, although it once flourished and was the marshal of the canopy, is now bloated and clumsy and unbearable for reuse.

Opera

 

        The Opera browser was released in 1994. It does not mark itself as its Mozilla like other browsers, but uses its own unique UA "Opera/9.51 (Windows NT 5.1; U; en)". But this persistence is also an important reason for the poor compatibility that has been criticized by Opera for a long time. Use normal webpage content in other browsers. When using Opera, the typography is often messed up or garbled, or the font color is too light to see clearly (especially Chinese fonts) - because most websites are mainly rendered in IE or early Mozilla Standard writing.

        In the end, for the sake of the market, Opera had to make some compromises, but it still did not simply and rudely label itself as Mozilla, but advocated letting users decide which browser to pretend to be. So the Opera browser created a menu option, allowing users to choose to become "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.51", or "Mozilla/5.0 (Windows NT 6.0; U; en; rv :1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.51", or "Opera/9.51 (Windows NT 5.1; U; en)".

        Because Opera's approach is very user-friendly and has achieved good results, the browsers or new versions of browsers that appear later, whether it is the Mozilla family, or IE and the core browser family with IE, or Konqueror, Safari, etc. , Chrome, and the team have followed suit, adding the function that the user can modify the UA—either provide several preset UAs for the user to choose like Opera, or provide the UA modification function so that the user can modify the UA to any content .

        However, due to Opera's uniqueness, although its reputation is very good and its functions are complete, its market share has not improved.

other derivative products

         It's been 28 years since the first web browser was released. The difficulty of browser development has also changed from the creation of top technology gods to the plaything of ordinary software engineers. In the market, browsers have sprung up like mushrooms after rain, presenting a situation where a hundred flowers are blooming. However, although there are a large number of browsers at present, the browsing cores they use are nothing more than Gecko, IE, KHTML (WebKit), and Opera. Therefore, the browser UA used by it almost all has an inheritance relationship with its predecessors. As far as the current situation is concerned, although the UA of each browser will be different, the following characteristics can be summarized as follows:

1. Almost all browsers provide UA modification function for users to pretend to be other browsers;

2. The default UA starts with Mozilla (except Opera).

3. Compared with PC browsers, mobile terminals often provide more convenient UA modification functions

4. Almost all of them provide three UA options to "disguise" as iPhone, ipad, and PC (IE).

        If the role of UA is regarded as a kind of camouflage, a very interesting conclusion will be drawn: Chrome disguises as Safari; Safari disguises as KHTML; KHTML disguises as Gecko; Gecko, IE disguises as Mozilla, and finally all browsers (only Opera) are all masquerading as Mozilla. As a browser, Mozilla has disappeared from the market, but it is still alive in the UA of other browsers.

        Microsoft can be said to be the "initiator" of this camouflage behavior, but every subsequent browser is imitating Microsoft's approach. Because, website developers often output some corresponding web page codes to realize special functions because of certain functions possessed by a certain browser. When other browsers also have these functions, they try to "disguise" This browser allows the website to output the same webpage code to itself, instead of the webpage code that has been castrated. Each browser is designed to give users the best content and browsing experience when visiting a website.

Appendix: Browser Default UA Encyclopedia

# 1、移动端

# Android N1

Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

# Android Pad Moto Xoom

Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

# BlackBerry

Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1 (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1

# QQ浏览器 For android

MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

# Opera浏览器

Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10

# safari iOS 4.33 – iPhone

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5

# 2、PC端浏览器

# 搜狗浏览器 1.x

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)

# Green Browser浏览器

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

# The World浏览器 2.x

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

# The World浏览器 3.x

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)

# Maxthon浏览器

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)

# TT浏览器

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)

# 360SE浏览器

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)


# safari 5.1 – Windows

Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50

# IE 9.0

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

# IE 8.0

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)

# IE 7.0

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)

# IE 6.0

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

# Firefox 4.0.1 – Windows

Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

# Opera 11.11 – Windows

Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11

# Chrome 17.0 – MAC

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11

Guess you like

Origin blog.csdn.net/weixin_42019349/article/details/130098155