Home What Is What is User Agent in Web Browser?

What is User Agent in Web Browser?

In the context of web browser, user agent is a string (a line of text) used by a web browser to tell a web server it connects to, regarding the information related to the browser itself. Commonly, this information contains the name of web browser itself, version, operating system and rendering engine. In other words, user agent is an identifier of a web browser. A web server needs to identify a web browser to be able to serve web pages based on the associated browser and the operating system on which the web browser runs on.

How a user agent works?

When you are browsing the net using a web browser, the web browser you use will always use a user agent as the identifier that tells every web server it connects to. Simply put, user agent is a way for web browser of saying “Hi, I am Google Chrome on Windows” or “Hi, I am Mozilla Firefox on Linux” to every web server it connects to. User agent itself is one of the components contained on HTTP header.

What is HTTP header?

A web browser and web server get communicate via HTTP protocol. A HTTP header is the code that transfers data between a web browser and web server. This data includes what is called user agent. For instance, if web browser’s user agent identifies itself as Chrome an iPhone, the web server will serve the mobile-specialized web pages to the browser. Conversely, if a web browser’s user agent identifies itself as Chrome on Windows 10, web server will serve the normal web pages to the browser. That is why you will see different display when accessing the same URL on iPhone via Chrome and on PC via Chrome as well.

How to see your browser’s user agent

There are several resources you can use to see the user agent of the web browser you are using. One of which is WhoIsHostingThis.com. Simply visit this page and you will see the user agent of you web browser. Following is the example of user agent of Google Chrome running on Windows 10.

You might be wondering. I use Chrome, but why there are words “Mozilla”, and “Gecko”?. As comparison, take a look at the user agent of Firefox that also runs on Windows 10.

It seems that everything is about Mozilla Firefox. You will also the words “Mozilla” and “Gecko” on the user agent of Microsoft Edge. Let’s figure out why this can happen.

A brief history of user agent in web browser

There is an unpopular browser called Mosaic. Despite its unpopularity, Mosaic is an old web browser. Older than Firefox and even Internet Explorer. At that moment, Mosaic’s user agent string was “NCSA_Mosaic/2.0”. Later, Mozilla emerged with the user agent of “Mozilla/1.0”. Mozilla was more modern than Mosaic. One of the advantages of Mozilla compared to Mosaic was that Mozilla supported frames. Web servers then checked to see if user agent contained the word “Mozilla” and sent pages that contain frames to Mozilla browsers. Web servers sent the old pages without frames to other browsers outside Mozilla.

And then Internet Explorer emerged in which supported frames as well. Even so, Internet Explorer didn’t receive modern pages with frames since web servers only sent those framed pages to Mozilla browsers. To fix this issue, Microsoft — the developer of Internet Explorer — added the word “Mozilla” to Internet Explorer’s user agent and added additional information (the word “compatible” and “a reference to IE”.). Later, other younger modern browsers did the same thing. Including Google Chrome.

In addition, some web servers also looked for the word “Gecko” and served Gecko based browsers different pages than older web browsers that didn’t use Gecko. Gecko itself is the rendering engine of Firefox.

Konqueror — which used KHTML — didn’t get the modern pages like the ones sent to Gecko. Eventually, KHTML added the words “like Gecko” so it would get the modern pages designed for Gecko as well.

Web browsers like Google Chrome, Safari and Opera use WebKit as their rendering engine. WebKit itself is based on KHTML. When it was developed, the developer of KHTML added the word “WebKit” and kept the original “KHTML, like Gecko” line for compatibility purposes.

Conclusion

User agent itself is not only exists on web browsers. Other software, including web crawler, also use the same identifier. In the context of web browser, user agent is used by web servers to:

  • Serve different pages to different web browsers. It can be simpler pages to older browsers or annoying things like “sorry, this page must be viewed in Microsoft Edge” message.
  • Display different contents for different operating systems. For instance, mobile operating systems like iOS and Android usually get slimmed-down pages
  • Gather statistics that show the web browsers and operating systems used by users. If you ever see browser market-share statistics (like this one), this is how they’re acquired.

.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

MOST-READ THIS WEEK