Headers and representations
Content negotiation
See how Accept headers let a client express preferences and how a server selects an available representation of a resource.
7 minute lesson
A resource can have more than one representation. The client states preferences with Accept headers:
Accept: text/html, application/json;q=0.8
Accept-Language: en, it;q=0.7
Accept-Encoding: br, gzip
The server chooses a supported option. Quality values such as q=0.8 make one option less preferred than another.
The server is not required to support every requested representation. An API may always return JSON. A site may use distinct URLs instead of negotiating language.
When a response changes according to a request header, caches need to know. A response such as Vary: Accept-Encoding tells a cache to keep different variants for different encoding preferences.
Quick check
Result
You got of right.
Lesson completed