Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax of User Agent in HTTP Header

I have Google Chrome Browser running version 89.0 The user agent of my browser displays the following string:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36

What does each field in the above syntax format represents ?

like image 386
vgokul129 Avatar asked Sep 02 '25 05:09

vgokul129


1 Answers

It’s entirely arbitrary what you put in the user agent field so there is no standard as to what format to use.

Saying that, for historical reasons, browsers like to claim to be lots of different browsers. Great post on that here: https://webaim.org/blog/user-agent-string-history/

This was mostly because some sites would use the user agent to guess the capabilities of the browser asking for a page and try to serve different versions depending what that said.

This was fraught with problems (hence why browsers had to pretend to be other to avoid getting a substandard page) and there are now much better ways to feature detect on the client side in CSS and JavaScript.

Additionally there are privacy issues with having such a specific version as with, along with just a few other items to make it more unique, it’s pretty easy to track individual users.

On the server side, User Agent Client Hints will allow a browser to tell the site what it supports, rather than a site guessing based on the user agent. Much more accurate and future proof.

Chrome has even said to it intends to freeze the user agent at some point to stop people depending on it. So I wouldn’t build anything depending on it.

like image 127
Barry Pollard Avatar answered Sep 05 '25 01:09

Barry Pollard