Hacker News new | ask | show | jobs
by 38 757 days ago
please stop doing stuff like this. its trivial to change the user-agent when making a request with a programming language, so any logic surrounding that should be non existent, or as simple as possible.

the user-agent string has an essentially arbitrary format, so its not really a good place to be reading data from, or worse serving a different response based on the value.

3 comments

It's a (minor) necessary evil that gives useful information. Almost no-one spoofs their user agent. I use this to pin down problems on the user side. Our users have all kinds of weird devices (e.g. browsing with a PlayStation) and it can be hard to find where things go wrong. There was a case where we lost more users than usual, and it turned out to be something very subtle related to tab switching in Safari. Without the user agent, we would never have found out.
> Almost no-one spoofs their user agent.

Citation needed

Ask one of your non-tech friends to spoof a user agent. And see if they even know what a user agent is.

They won’t.

But also, what exactly were you expecting out of a citation? A survey done about whether people spoof their UA or not? That doesn’t exist and likely never will.

This is useful.

If you have a website, you want to collect statistical data on which browsers are accessing your website and test for the best experiences on the top browsers.

that sounds nice, but history has shown thats never what happens.

what REALLY happens is the most popular browser and even version is determined, and anything thats not that doesn't get tested, and eventually breaks. its the pinnacle of lazy programming. "lets use telemetry so that we can point to data that allows us to make software thats as brittle as possible".

There are limited resources in the world. The bulk of the resources should go to the bulk of the users. It’s a feature that rare configurations are less tested
(Former browser dev)

Agreed. Feature detection is the way, not UA sniffing.

Whoosh