ChromeがUserAgentを廃止する意図

UserAgentといえばIEだろうがChromeだろうが「Mozilla/5.0」という文字列が含まれる摩訶不思議な情報だったが、これに終止符が打たれるようだ。

https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/-2JIRNMWJ7s/yHe4tQNLCgAJ

The User-Agent string is an abundant source of passive fingerprinting information about our users. It contains many details about the user’s browser and device as well as many lies ("Mozilla/5.0", anyone?) that were or are needed for compatibility purposes, as servers grew reliant on bad User Agent sniffing.

User-Agentはユーザのfingerprintingとして有用な情報だが、互換性のために多くの嘘(ChromeなのにMozilla/5.0といった文字列が含まれるなど)が含まれている。これはサーバがUser-Agentを見てSniffing、つまりブラウザによってどう表示するか制御するようになったことも一因だ。

The above abuse makes it desirable to freeze the UA string and replace it with a better mechanism. There have been past attempts at UA string freezing from the Safari team, but without an alternative way to perform UA based content-negotiation, they had to be partially reverted.

そういったabuse(悪用)が横行していることから、UAについてはfreezeして、よりよいメカニズムに置き換えることが望ましい。過去にSafariが取り組んだことがあったがUAベースでのコンテンツのネゴシエーションを代替することができなく、Safariチームは部分的に元に戻さざるをえなかった。

The User Agent Client Hints (UA-CH) feature provides an alternate source for the information the User-Agent string provides, both in its request header form as well as its JS API one.

UA-CH(User Agent Client Hints)はリクエストヘッダとJS APIの療法でUser-Agentを提供するための代替手段となる。

スクリーンショット 2020-01-20 22.47.01

これを2020年の3月、6月、9月の3段階で移行する。

Serving different Web pages or services to different browsers is usually a bad idea. The Web is meant to be accessible to everyone, regardless of which browser or device they're using. There are ways to develop your website to progressively enhance itself based on the availability of features rather than by targeting specific browsers.

Mozillaも「ブラウザごとに異なるページを表示するのは悪いアイデアだ」と断言している。

So, user agent sniffing is definitely not the way to go. Thankfully, there are much better alternatives. Use Navigator.maxTouchPoints to detect if the user's device has a touchscreen.

ユーザがスマートフォンやタブレットを使っていてタッチ操作ができるかどうか調べたい場合はUser-Agentなんかで検知するのではなく、タッチ操作ができるかどうかをJavaScriptで確認すればよい。


この記事が気に入ったらサポートをしてみませんか?