时间爱人

为什么所有主要浏览器的User-Agent都是Mozilla/5.0开头

你是否好奇标识浏览器身份的User-Agent,为什么每个浏览器都有Mozilla字样?

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

Mozilla/5.0 (Linux; U; Android 4.1.2; zh-tw; GT-I9300 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)

故事还得从头说起,最初的主角叫NCSA Mosaic,简称Mosaic(马赛克),是1992年末位于伊利诺伊大学厄巴纳-香槟分校的国家超级计算机应用中心(National Center for Supercomputing Applications,简称NCSA)开发,并于1993年发布的一款浏览器。它自称“NCSA_Mosaic/2.0(Windows 3.1)”,Mosaic可以同时展示文字和图片,从此浏览器变得有趣多了。

然而很快就出现了另一个浏览器,这就是著名的Mozilla,中文名称摩斯拉。一说 Mozilla = Mosaic + Killer,意为Mosaic杀手,也有说法是 Mozilla = Mosaic & Godzilla,意为马赛克和哥斯拉,而Mozilla最初的吉祥物是只绿色大蜥蜴,后来更改为红色暴龙,跟哥斯拉长得一样。

但Mosaic对此非常不高兴,于是后来Mozilla更名为Netscape,也就是网景。Netscape自称“Mozilla/1.0(Win3.1)”,事情开始变得更加有趣。网景支持框架(frame),由于大家的喜欢框架变得流行起来,但是Mosaic不支持框架,于是网站管理员探测user agent,对Mozilla浏览器发送含有框架的页面,对非Mozilla浏览器发送没有框架的页面。

后来网景拿微软寻开心,称微软的Windows是“没有调试过的硬件驱动程序”。微软很生气,后果很严重。此后微软开发了自己的浏览器,这就是Internet Explorer,并希望它可以成为Netscape Killer。IE同样支持框架,但它不是Mozilla,所以它总是收不到含有框架的页面。微软很郁闷很快就沉不住气了,它不想等到所有的网站管理员都了解IE并且给IE发送含有框架的页面,它选择宣布IE是兼容Mozilla,并且模仿Netscape称IE为“Mozilla/1.22(compatible; MSIE 2.0; Windows 95)”,于是IE可以收到含有框架的页面了,所有微软的人都嗨皮了,但是网站管理员开始晕了。

因为微软将IE和Windows捆绑销售,并且把IE做得比Netscape更好,于是第一次浏览器血腥大战爆发了,结果是Netscape以失败退出历史舞台,微软更加嗨皮。但没想到Netscape居然以Mozilla的名义重生了,并且开发了Gecko,这次它自称为“Mozilla/5.0(Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826”。

Gecko是一款渲染引擎并且很出色。Mozilla后来变成了Firefox,并自称“Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.7.5) Gecko/20041108 Firefox/1.0”。Firefox性能很出色,Gecko也开始攻城略地,其他新的浏览器使用了它的代码,并且将它们自己称为“Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.2) Gecko/20040825 Camino/0.8.1”,以及“Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.8) Gecko/20071008 SeaMonkey/1.0”,每一个都将自己装作Mozilla,而它们全都使用Gecko。

Gecko很出色,而IE完全跟不上它,因此user agent探测规则变了,使用Gecko的浏览器被发送了更好的代码,而其他浏览器则没有这种待遇。Linux的追随者对此很难过,因为他们编写了Konqueror,它的引擎是KHTML,他们认为KHTML和Gecko一样出色,但却因为不是Gecko而得不到好的页面,于是Konqueror为得到更好的页面开始将自己伪装成“like Gecko”,并自称为“Mozilla/5.0 (compatible; Konqueror/3.2; FreeBSD) (KHTML, like Gecko)”。自此user agent变得更加混乱。

这时更有Opera跳出来说“毫无疑问,我们应该让用户来决定他们想让我们伪装成哪个浏览器。”于是Opera干脆创建了菜单项让用户自主选择让Opera浏览器变成“Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.51”,或者“Mozilla/5.0 (Windows NT 6.0; U; en; rv:1.8.1) Gecko/20061208 Firefox/2.0.0 Opera 9.51”, 或者“Opera/9.51 (Windows NT 5.1; U; en)”。

后来苹果开发了Safari浏览器,并使用KHTML作为渲染引擎,但苹果加入了许多新的特性,于是苹果从KHTML另辟分支称之为WebKit,但它又不想抛弃那些为KHTML编写的页面,于是Safari自称为“Mozilla/5.0 (Macintosh; U; PPC Mac OS X; de-de) AppleWebKit/85.7 (KHTML, like Gecko) Safari/85.5”,这进一步加剧了user agent的混乱局面。

因为微软十分忌惮Firefox,于是IE重装上阵,这次它自称为“Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ”,并且渲染效果同样出色,但是需要网站管理员的指令它这么做才行。

再后来,谷歌开发了Chrome浏览器,Chrome使用Webkit作为渲染引擎,和Safari之前一样,它想要那些为Safari编写的页面,于是它伪装成了Safari。于是Chrome使用WebKit,并将自己伪装成Safari,WebKit伪装成KHTML,KHTML伪装成Gecko,最后所有的浏览器都伪装成了Mozilla,这就是为什么所有的浏览器User-Agent里都有Mozilla。Chrome自称为“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”。

因为以上这段历史,现在的User-Agent字符串变得一团糟,几乎根本无法彰显它最初的意义。追根溯源,微软可以说是这一切的始作俑者,但后来每一个人都在试图假扮别人,最终把User-Agent搞得混乱不堪。

一句话结论:因为网站开发者可能会因为你是某浏览器(这里是 Mozilla),所以输出一些特殊功能的程序代码(这里指好的特殊功能),所以当其它浏览器也支持这种好功能时,就试图去模仿 Mozilla 浏览器让网站输出跟 Mozilla 一样的内容,而不是输出被阉割功能的程序代码。大家都为了让网站输出最好的内容,都试图假装自己是 Mozilla 一个已经不存在的浏览器……

  附:各大浏览器诞生年表:

根据考证,世界上第一个浏览器是WorldWideWeb,诞生于1990年。 而第一个普及的,是由NCSA开发的Mosaic浏览器。

1993年1月23日:Mosaic Alpha,同年3月推出0.1版本,它实际上也是Netscape与IE的共同祖先。

1994年12月:Netscape 1.0(Mozilla/1.0)

1994年:Opera,基于Elektra排版引擎(已成为历史)。

1995年8月16日:Internet Explorer 1.0(Mozilla/1.22)

1996年10月14日:Kongqueror浏览器,基于KHTML引擎,主要应用于 Linux 和 BSD家族的操作系统。

1998年,Windows98横空出世,捆绑了IE4.0,Netscape最终被彻底地打败!

1998年11月24日,美国在线AOL宣布收购Netscape公司。之后将所有Netscape的浏览器原始代码都送给了开源社群自行开发,并成立开源社区Mozilla(mozilla.org)。

2000年11月:网景公司正式发布Netscape 6.0,基于新一代的排版引擎Gecko。

2001年10月,微软发布Windows XP,因为忌惮Firefox的性能优势,XP系统捆绑发布了Internet Explorer 6.0(Mozilla/4.0)。

2003年1月7日:Safari beta,基于KHTML排版引擎。

2003年6月,Opera7.0,启用Presto排版引擎。

2003年7月15日,美国在线AOL解散了网景公司Netscape,而Mozilla基金会亦在当天成立,它就是现在Firefox浏览器的管理和推进组织,从此FireFox成了削弱IE市场份额的一只重要棋子,Netscape的借尸还魂术宣告成功。

2003年,苹果推出了采用WebKit引擎的浏览器 Safari。

2004年11月9日:Mozilla基金会发布了Firefox的第一个正式版本1.0(Mozilla/5.0),基于Gecko排版引擎。

2005年,苹果宣布将WebKit完全开源(之前仅有从KHTML直接搬来的WebCore及JavaScriptCore是开源的)。

2008年9月2日:Chrome,基于Chromium引擎,WebKit的一个分支。。

2010年4月,苹果公司宣布了其浏览器引擎Webkit的最新项目Webkit2。

2013年2月,Opera宣布将用WebKit替代当前的核心浏览器引擎Presto。

2013年4月3日,谷歌宣布将与苹果的开源浏览器核心Webkit分道扬镳,在Chromium项目中研发Blink渲染引擎,内置于Chrome浏览器之中。

2013年4月,Opera又宣布放弃WEBKIT,跟随GOOGLE的新开发的Blink引擎。

2015年6月7日,Windows10预览版,启用Microsoft Edge浏览器名称,WebCore是EdegHTML,JSCore是Chakra。

2016年1月12日起,微软停止为IE8/9/10这些旧版本的IE浏览器提供技术支持,Internet Explorer正式退出。

2,535 thoughts on “为什么所有主要浏览器的User-Agent都是Mozilla/5.0开头

  1. Pretty nice post. I just stumbled upon your weblog and wanted to say that I’ve really enjoyed surfing around your blog posts.
    After all I will be subscribing to your feed and I hope you write again very soon!

  2. Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something.
    I think that you can do with some pics to drive the message
    home a bit, but other than that, this is wonderful blog.
    A fantastic read. I will certainly be back.

  3. The other day, while I was at work, my cousin stole
    my iphone and tested to see if it can survive a thirty
    foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83
    views. I know this is entirely off topic but I had to share it with someone!

  4. Excellent beat ! I wish to apprentice whilst you amend your website,
    how can i subscribe for a blog site? The account helped me a appropriate deal.
    I were a little bit acquainted of this your broadcast
    provided bright transparent idea

  5. I loved as much as you’ll receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get bought an shakiness over that
    you wish be delivering the following. unwell unquestionably come further
    formerly again since exactly the same nearly a lot often inside case you shield this increase.

  6. I’m amazed, I have to admit. Rarely do I come across a blog that’s equally educative and
    entertaining, and let me tell you, you’ve hit the nail on the head.

    The issue is something which too few men and women are speaking intelligently about.

    I’m very happy that I found this in my hunt for something relating to this.

  7. Hi there! Someone in my Facebook group shared this site with us so I came to give it a look.
    I’m definitely enjoying the information. I’m bookmarking and will be tweeting this
    to my followers! Exceptional blog and excellent design and style.

  8. Its such as you read my thoughts! You appear to grasp
    so much about this, like you wrote the e-book in it or something.
    I believe that you just can do with a few % to drive the message house a
    little bit, but instead of that, this is wonderful blog.
    A great read. I’ll certainly be back.

  9. Thank you for the good writeup. It in reality was once a entertainment account it.
    Look complicated to far introduced agreeable from you!
    However, how can we communicate?

  10. Howdy I am so excited I found your blog, I really found you by mistake, while I
    was searching on Bing for something else, Anyways I am
    here now and would just like to say many thanks for a
    marvelous post and a all round entertaining blog (I also love the theme/design),
    I don’t have time to go through it all at the minute but I have saved it and also added in your RSS feeds, so when I have time I will be back to read a lot more,
    Please do keep up the awesome jo.

  11. What’s Happening i am new to this, I stumbled upon this
    I’ve found It positively helpful and it has helped me out loads.
    I’m hoping to contribute & help different customers like its
    aided me. Great job.

  12. Hi there would you mind sharing which blog platform you’re using?
    I’m planning to start my own blog soon but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique.
    P.S My apologies for getting off-topic but I had to ask!

  13. Hello! I’ve been reading your website for a while now and finally
    got the bravery to go ahead and give you a shout out from Atascocita Tx!
    Just wanted to mention keep up the good job!

  14. Hello there! This article could not be written any better!
    Going through this post reminds me of my previous
    roommate! He constantly kept talking about this. I most certainly will send this article
    to him. Pretty sure he will have a great read.
    Many thanks for sharing!

  15. Woah! I’m really digging the template/theme of this website.

    It’s simple, yet effective. A lot of times it’s very hard to get that
    “perfect balance” between usability and visual appearance.

    I must say that you’ve done a excellent job with this.
    In addition, the blog loads super quick for me on Chrome.
    Superb Blog!

  16. Hello! Do you know if they make any plugins to assist with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not
    seeing very good success. If you know of any please share.
    Thank you!

  17. It is great to look around as well as compare
    the prices of downloading movies online. Some internet
    sites will bill you per download or monthly registration. There are additionally many others which charge you a level price to download and install
    endless films.

    Downloading films online can be convenient if you understand
    what to do. Get much more warm suggestions from my blog site and check
    out the favorite flick websites of today.

    This article may be easily reprinted or dispersed in its whole in any kind of ezine, newsletter,
    blog or web site. The author’s name, bio and also internet site web links need to remain intact
    and be included with every reproduction.

  18. Hi! This is my 1st comment here so I just wanted to give a quick shout out and say I truly enjoy
    reading your blog posts. Can you suggest any other blogs/websites/forums that
    deal with the same topics? Many thanks!

  19. And ask us any questions you have about our service or expertise.
    In case you have any questions about our plans, or what you can do with one,
    just ask. You possibly can create your own miniature sites
    and put links to your hubs on these pages. Actually,
    most sites that I plan to host are mine, as well as those of some previous and faithful shoppers.
    My suggestion is to keep away from sites that declare to supply backlinks, each free and paid.
    It is usually free and open source with its source is available
    on GitHub. Need 5 Days Free Trial Then Feel free To Contact Us.

    Price: Previously days there was important difference between unmanaged VPS
    and managed VPS companies but nowadays this isn’t the scenario.
    Speaking of the bargains, one of my favorite ones is how inexpensive it’s to move
    to a managed VPS platform.

  20. Hey excellent blog! Does running a blog like this require a
    massive amount work? I’ve no understanding of programming but I
    had been hoping to start my own blog soon. Anyway, should you have any suggestions or techniques
    for new blog owners please share. I know this is off topic nevertheless I simply
    needed to ask. Cheers!

  21. As an associate, you will certainly have an ad on your website that might perhaps
    draw in potential consumers to that certain company’s web site, where they can download and install and evaluate numerous
    products. When the client chooses to acquire, the internet store
    driver can figure out where affiliate the sale came, based upon a cookie placed previously right into the consumer’s browser.
    The associate is after that paid a set portion of the sale amount.

    How to come to be a part of this …

    So now that you know what all this implies, exactly
    how would certainly you such as to come to be an affiliate absolutely
    free and also begin earning money or be the boss of your very own online video clip store, renting out DVDs?
    In instance you assume it is excessive problem to pursue, you would certainly be amazed at just exactly how easy it
    really is. By belonging to the affiliate program,
    you can earn money merely by referring your household,
    buddies, colleagues and neighbors to this exciting program of E3Flix.

    What’s even more, it doesn’t also cost you to join.

  22. Have you ever considered about adding a little bit more than just your
    articles? I mean, what you say is valuable and everything.
    Nevertheless think about if you added some great pictures or video clips to give your posts more, “pop”!
    Your content is excellent but with pics and videos, this website could definitely be one of the most beneficial in its field.
    Awesome blog!

  23. I know this if off topic but I’m looking into starting my own blog and was
    curious what all is needed to get set up?
    I’m assuming having a blog like yours would cost a pretty
    penny? I’m not very web smart so I’m not 100% sure. Any recommendations or advice would be greatly
    appreciated. Appreciate it

发表评论

电子邮件地址不会被公开。 必填项已用*标注

答案 : *
19 − 12 =


Back To Top