时间爱人

为什么所有主要浏览器的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正式退出。

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

  1. People can find it rather useful for themselves to download flicks at their homes without needing to spend unnecessary cash on very valued DVD movies that can either be bought or rented
    out from retail shops. They don’t need to
    stress over investing some additional on their automobile fuel just because of their little and constant visits to retail stores.
    Sometimes the stores go to a country mile and visiting them could not be so cost-effective for you as well as your
    family. So, what’s more useful than enjoying your favored flick or video clip in the
    house, sitting in front of your Computer or TV as well as have the flick downloaded and install quickly.
    You can see your personal favored movies anytime by saving the downloaded documents and you don’t
    need to rent out the same motion picture every single time.

    Similarly, you may wind up returning from the store vacant handed just since
    the store has run except the film or flick that you wanted.

    The on the internet movie websites supply their individuals and
    movie fans with an infinite collection of films.
    Also the international films can be downloaded
    and install from some well reputed and also trusted
    websites that supply the motion pictures in an authorized method.

  2. I do agree with all of the ideas you’ve introduced for your post.

    They’re really convincing and can definitely work. Still, the posts are very quick for novices.
    Could you please lengthen them a bit from next time?
    Thanks for the post.

  3. I have been browsing on-line greater than three hours these days, yet I
    never found any attention-grabbing article like yours.
    It is pretty worth sufficient for me. In my view,
    if all site owners and bloggers made just right content material as you probably
    did, the web will be much more useful than ever before.

  4. Hi I am so thrilled I found your weblog, I really found you by error, while I was looking
    on Digg for something else, Regardless I am here now and would just like to say thanks for a remarkable post and a all round
    enjoyable blog (I also love the theme/design), I don’t have
    time to look over it all at the minute but I
    have bookmarked it and also added in your RSS feeds, so when I have
    time I will be back to read more, Please do keep up the superb b.

  5. Hey There. I found your blog using msn. This is a really
    well written article. I will make sure to bookmark it and return to read more
    of your useful information. Thanks for the post.
    I will definitely return.

  6. I’m really enjoying the theme/design of your site. Do you ever run into any browser compatibility problems?
    A number of my blog visitors have complained about my website not operating correctly in Explorer
    but looks great in Opera. Do you have any ideas to help fix this problem?

  7. Whats up very cool site!! Guy .. Beautiful .. Superb ..
    I’ll bookmark your website and take the feeds additionally?
    I am happy to search out a lot of useful information right here in the post, we’d like develop extra techniques on this
    regard, thank you for sharing. . . . . .

  8. Howdy! I realize this is somewhat off-topic but I had to
    ask. Does operating a well-established website such as yours require a large amount of work?

    I’m brand new to blogging but I do write in my diary everyday.
    I’d like to start a blog so I can share my experience
    and views online. Please let me know if you have any
    ideas or tips for new aspiring bloggers. Thankyou!

  9. It’s a shame you don’t have a donate button! I’d certainly donate to
    this excellent blog! I suppose for now i’ll settle for
    book-marking and adding your RSS feed to my Google account.
    I look forward to new updates and will share this site with my Facebook group.
    Chat soon!

  10. Hello there, I believe your website might be having browser compatibility issues.
    Whenever I take a look at your blog in Safari, it looks fine however, when opening in Internet Explorer, it has some overlapping issues.
    I simply wanted to provide you with a quick heads up!

    Besides that, great site!

  11. Greetings from Colorado! I’m bored at work so I decided to browse
    your site on my iphone during lunch break. I enjoy the knowledge you
    present here and can’t wait to take a look when I get home.
    I’m shocked at how fast your blog loaded on my cell phone ..
    I’m not even using WIFI, just 3G .. Anyhow, fantastic blog!

  12. Simply want to say your article is as amazing.
    The clarity in your post is simply cool and i could assume
    you are an expert on this subject. Fine with your permission let me
    to grab your feed to keep updated with forthcoming post.
    Thanks a million and please continue the rewarding work.

  13. You really make it appear so easy with your presentation but I in finding this topic to be
    actually something which I believe I would by no means understand.
    It kind of feels too complicated and extremely large for me.
    I’m looking forward on your subsequent publish, I’ll attempt to get
    the cling of it!

  14. Hey һere outstanding website!Doees running a blog similɑr to this takе a
    large amoujnt of work? I’ve nno expertise in computer programming but I was hoping to start my own blog in the near future.
    Anyway, should you hwve ɑnyy suggestions or techniques for new bloց
    owneгs please share. I know this is offf subject nevertheless I just neede to ask.

    Thank you!

  15. Have yоu ever considered publishing an e-booк or guest
    authoring on other websites? Ihavfe a bllog centered on thhe same ideas you discusѕ
    and would love to haɡe you shaare some stories/infօrmation. I knoᴡ my audience would enjoy youг work.
    If yߋu aгe even remotely interested, feel frree to send me an e mail.

  16. I’m гeally impressed with yߋpur writing skillѕ and also ԝitһ the layout on your weblog.

    Is this a paid theme or did you customize it yoursеlf?

    Anywaү keep up the excellent qualitу wгiting, it’s are to see
    a great blog lik this one these days.

  17. Great beat ! I wish to apprentice whilst you amend
    your website, how can i subscribe for a blog site? The account aided me a appropriate deal.
    I have been tiny bit familiar of this your broadcast offered vibrant clear concept

  18. I have read some excellent stuff here. Definitely worth bookmarking for revisiting.
    I wonder how so much effort you put to create one of these
    fantastic informative site.

  19. Excellent beat ! I wish to apprentice even as you amend your web site, how can i subscribe for a blog site?
    The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright transparent concept

  20. First off I would like to say fantastic blog!

    I had a quick question which I’d like to ask if you don’t mind.
    I was interested to find out how you center yourself and clear your
    head before writing. I have had a difficult time clearing my thoughts in getting my ideas out there.
    I do enjoy writing however it just seems like the first 10 to 15
    minutes are generally wasted just trying to figure out how to begin. Any suggestions or tips?
    Kudos!

发表评论

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

答案 : *
11 + 23 =


返回顶部