用户代理字符串的目的?

User agent strings purpose?

浏览器代理字符串的用途是什么?如果它提供有关用户访问网站的浏览器的信息,但它可以被欺骗;我看不出有什么理由。

因为它提供了有关用户访问网站的浏览器的信息。

网站可以使用用户代理header来呈现不同的体验。例如,如果浏览器为 iPhone 提供 user-agent 字符串,该站点可能 return 302 重定向到移动用户体验。如果它为非常旧的浏览器提供 user-agent 字符串,该站点可能 return 重定向到下层用户体验,例如一种不需要 javascript,一种不需要 HTML5.

当然,它可以被欺骗;很多其他的东西也可以。不知道为什么你认为这会否定它的使用。对于 non-malicious 用户来说,定制网站非常方便。

来自the specification

The "User-Agent" header field contains information about the user agent originating the request, which is often used by servers to help identify the scope of reported interoperability problems, to work around or tailor responses to avoid particular user agent limitations, and for analytics regarding browser or operating system use.

... 就欺骗而言:

If a user agent masquerades as a different user agent, recipients can assume that the user intentionally desires to see responses tailored for that identified user agent, even if they might not work as well for the actual user agent being used.