Search code examples
httpcontent-negotiation

Is HTTP content negotiation being used by browsers and servers in practice?


I'm learning about HTTP content negotiation at the moment. I already understand the basic way client and server are able to negotiate a representation for the content requested.

I could not find out, though, what content negotiation is actually good for. Are real world browsers actively using any of this? I understand they are sending some headers such as Accept but their content and meaning seems vaguely defined to be.

I also wonder if real-world web applications can make use of HTTP content negotiation. Would a realistic web application ever return different data based on these headers? How could a server meaningfully decide based on the q-factor?

My goal is to understand how real web apps work in this regard so that I can better decide which parts of HTTP content negotiation I want to learn and use.

Maybe the answer is just that this is not being used in practice which would be a valid answer to me. Concrete examples for use cases would also help.


Solution

  • It's definitely used a lot, for instance to negotiate formats (using "Accept", such as for image/webp), compression codings (using "Accept-Encoding", such as for brotli) or different languages (using "Accept-Language").