boot4life
boot4life

Reputation: 5324

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.

Upvotes: 2

Views: 301

Answers (2)

Julian Reschke
Julian Reschke

Reputation: 42045

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").

Upvotes: 2

Yes. It is surely used for multi-language pages (a web site displaying different pages for French & English users)

I would also imagine that some web interface to a version control system could use the Accept: header to display (when showing some C source file) either the raw C file or some HTML formatted version of it.

Upvotes: 1

Related Questions