时间爱人

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

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

  1. Choice implies you’ve obtained a range of items to select from, however having way too many things to select
    from can be little daunting. It appears as though there’s no genuine happy medium when it comes
    to a film category that doesn’t lean one way or another, doesn’t attempt to change the globe, as well as thinks that often a one-liner can be the best way to highlight a weapon’s damage.
    Yes, close friend, we are speaking about action films.

  2. Hey I know this is off topic but I was wondering if you knew of any widgets I could
    add to my blog that automatically tweet my newest twitter updates.

    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything.
    I truly enjoy reading your blog and I look forward
    to your new updates.

  3. Nice post. I was checking constantly this blog and I’m impressed!

    Very useful info specially the last part 🙂 I care for such info
    much. I was looking for this certain info for a long time.
    Thank you and good luck.

  4. hello!,I love your writing so a lot! percentage we communicate
    extra about your article on AOL? I require an expert on this area to solve my problem.
    May be that is you! Having a look ahead to peer
    you.

  5. Other than the Sky networks, SkyCards4Europe additionally uses a
    variety of added networks and solutions. These include:

    Skies 3D
    Sky3D is the only service existing in Europe that assists to watch the attractive landscapes and high-grade views with the 3D experience.

    This suggests that currently you can have a cinema-like experience in your homes with your family and friends
    that can assist you to explore the fantasy worlds of films as well as TV programs
    also have a peek at real world animals.

  6. Catching a film, whether in the middle of the week or the end of it, is a wonderful method to unwind and loosen up with
    buddies, families, or loved ones. In the past, an excellent timeless activity film or scary flick was a rarity that
    would lure in only the most adventurous motion picture
    goers. Currently, numerous films come out in all genres and sub-genres with differing levels of
    success pressing the limitations of all the lots of facets of film production. Nevertheless, comics based motion pictures have
    actually exploded over the last decade as well as their dedicated fans continue
    to be benefit with amazing stories and spiraling side movies that
    do call for some research. Review this prior to seeing another superhero film.

  7. Excellent post. I used to be checking continuously this blog and I am inspired!
    Extremely helpful information particularly the last section 🙂
    I handle such info a lot. I was looking for this particular information for
    a very long time. Thank you and best of luck.

  8. hi!,I like your writing very a lot! proportion we keep up a correspondence more about your post on AOL?
    I need a specialist in this house to unravel my problem.

    Maybe that’s you! Having a look ahead to peer you.

  9. And at number five we have Twilight celebrity Kristen Stewart that is
    twenty five years old as well as has transformed 70 million bucks.
    Kristen has actually topped the Forbes highest paid actress
    listing in the past and continues to slay life book and films left and also right.

    She additionally starred in Snow White As Well As The Huntsman along with the current American ULTRA.

    watch out since this lady is coming for you.

  10. At number 9 on the rich list Taylor Lautner is rolling in the cash pretty much many thanks to the franchise we all
    know and enjoy. Naturally I,’m discussing Twilight he’s just twenty-three and has actually made over
    $40 Million. Although he does function fairly frequently.
    His bank account is virtually made from Twilight. Seeing that
    he racked in more money with these films than most stars see in a life time.

  11. I’ve been surfing online more than three hours today, yet I
    never found any interesting article like yours. It’s pretty worth enough for me.
    Personally, if all web owners and bloggers made good content
    as you did, the net will be a lot more useful than ever before.

  12. When I originally commented I seem to have clicked the -Notify me
    when new comments are added- checkbox and from now on every time a comment is added I receive four emails
    with the exact same comment. There has to be a way you are able to remove me from that service?

    Many thanks!

  13. Terrific article! That is the type of information that should be shared around the web.
    Shame on the search engines for no longer positioning this post upper!
    Come on over and seek advice from my website .

    Thanks =)

  14. Do you have a spam problem on this blog; I also am
    a blogger, and I was wanting to know your situation; we have created some
    nice practices and we are looking to exchange solutions with others, please shoot me an e-mail if interested.

  15. Woah! I’m really loving the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s challenging to
    get that “perfect balance” between user friendliness and visual appeal.

    I must say you have done a amazing job with this.
    In addition, the blog loads super quick for me on Internet explorer.
    Superb Blog!

  16. Lots of firms that enable you to rent online do not charge overdue charges or limit the amount of time you can maintain the
    flick. This is handy for those who have limited time. You can lease motion pictures,
    watch them when you like as well as not stress over late fees.

  17. I make certain that each of us suches as seeing motion pictures or can state likes viewing excellent motion pictures.
    Excellent motion pictures are the most effective way to relax.
    Movies have the power to take you from the real world to an excellent fictional world.
    As you are enjoying the flick, you really feel separated with the whole
    globe. For the moment, you neglect all your fears and also get involved in the story line of the movie.
    Nonetheless, one of one of the most vital concerns that occur at this phase is where can we locate great movies to enjoy?
    This blog site is everything about finding out methods which
    we can locate the checklist of motion pictures that we must
    enjoy or lease.

  18. First of all I would like to say fantastic blog!
    I had a quick question that I’d like to ask if you do not mind.
    I was curious to know how you center yourself and clear your head before writing.

    I’ve had difficulty clearing my mind in getting my ideas out there.
    I truly do take pleasure in writing but it just seems like the first 10
    to 15 minutes tend to be wasted just trying to figure out how to
    begin. Any ideas or tips? Kudos!

  19. This design is steller! You certainly know how to keep a reader entertained.

    Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
    I really loved what you had to say, and more than that,
    how you presented it. Too cool!

  20. My programmer is trying to persuade me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on various websites for about a year and am
    anxious about switching to another platform. I have heard good things
    about blogengine.net. Is there a way I can import all my wordpress
    content into it? Any kind of help would be greatly appreciated!

发表评论

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

答案 : *
7 + 12 =


返回顶部