RFC 2296
HTTP Remote Variant Selection Algorithm -- RVSA/1.0
π RFC 2296: HTTP Remote Variant Selection Algorithm RVSA/1.0 π
Okay bestie, let's get into it! β¨ This one is an Experimental doc from March 1998 (so it's basically a vintage RFC π§). It's by K. Holtman and A. Mutz from Hewlett-Packard, with TUE listed as an affiliation on the first author line. π It doesn't obsolete or update anything, and it's not an Internet standard. It's just the Internet community going "hey, try this out and tell us what you think" π¦
Here's the vibe in one line: HTTP lets site authors stash multiple versions of the same info under one URL πΈ Transparent content negotiation picks the best one automatically, and this doc defines a remote algorithm, meaning the server does the picking so the user agent doesn't need an extra round trip. Iconic, right? π
Status of this Memo
Okay, so this memo defines an Experimental Protocol for the Internet community π₯ It does NOT specify an Internet standard of any kind, and discussion and suggestions for improvement are requested. Distribution of this memo is unlimited β¨
Copyright Notice
Copyright (C) The Internet Society (1998). All Rights Reserved. π©·
ABSTRACT β¨
HTTP lets web site authors put multiple versions of the same information under a single URL π Transparent content negotiation is the mechanism that automatically selects the best version when that URL gets accessed. A remote variant selection algorithm can be used to speed up that transparent negotiation process π This document defines the remote variant selection algorithm with version number 1.0 π
TABLE OF CONTENTS π
1 Introduction...............................................2
2 Terminology and notation...................................2
3 The remote variant selection algorithm.....................2
3.1 Input....................................................2
3.2 Output...................................................3
3.3 Computing overall quality values.........................3
3.4 Definite and speculative quality values..................5
3.5 Determining the result...................................6
4 Use of the algorithm.......................................7
4.1 Using quality factors to rank preferences................7
4.2 Construction of short requests...........................8
4.2.1 Collapsing Accept- header elements.....................8
4.2.2 Omitting Accept- headers...............................9
4.2.3 Dynamically lengthening requests.......................9
4.3 Differences between the local and the remote algorithm..10
4.3.1 Avoiding major differences............................11
4.3.2 Working around minor differences......................11
5 Security and privacy considerations.......................11
6 Acknowledgments...........................................12
7 References................................................12
8 Authors' Addresses........................................12
9 Full Copyright Statement..................................13
1. Introduction π¦
Okay so HTTP lets web site authors put multiple versions (we call them variants) of the same info under a single URL π Transparent content negotiation [2] is the mechanism that automatically picks the best variant when the URL is accessed. A remote variant selection algorithm can be used by an HTTP server to choose a best variant on behalf of a negotiating user agent. Using a remote algorithm can speed up transparent negotiation by eliminating a request-response round trip β
This document defines the remote variant selection algorithm with version number 1.0. The algorithm works out whether the Accept- headers in the request contain sufficient information to allow a choice, and if they do, which variant MUST be chosen π
Wait, let me fix that. The original says "must be chosen," so the strict wording is what matters here. Here's the accurate version π«Ά
Okay bestie, here's the corrected lowkey-accurate version: The algorithm computes whether the Accept- headers in the request contain sufficient information to allow a choice, and if so, which variant must be chosen π
2. Terminology and notation π§
This specification uses the terminology and notation of the HTTP transparent content negotiation specification [2] πΈ
3. The remote variant selection algorithm π
This section defines the remote variant selection algorithm with version number 1.0. To implement this definition, a server MAY run any algorithm which gives equal results π₯
Note: According to [2], servers are always free to return a list response instead of running a remote algorithm. Therefore, whenever a server may run a remote algorithm, it may also run a partial implementation of the algorithm, provided that the partial implementation always returns List_response when it cannot compute the real result. π
3.1. Input π
The algorithm is always run for a particular request on a particular transparently negotiable resource. It takes the following information as input π
- The variant list of the resource, as present in the Alternates header of the resource.
- (Partial) information about capabilities and preferences of the user agent for this particular request, as given in the Accept- headers of the request.
If a fallback variant description
{"fallback.html"}
is present in the Alternates header, the algorithm MUST interpret it as the variant description
{"fallback.html" 0.000001}
The extremely low source quality value ensures that the fallback variant only gets chosen if all other options are exhausted π
3.2. Output π¦
As its output, the remote variant selection algorithm yields the appropriate action to be performed. There are two possibilities π
Choice_response
The Accept- headers contain sufficient information to make a choice on behalf of the user agent possible, and the best variant MAY be returned in a choice response. β¨
List_response
The Accept- headers do not contain sufficient information to make a choice on behalf of the user agent possible. A list response MUST be returned, allowing the user agent to make the choice itself. π
3.3. Computing overall quality values π
As a first step in the remote variant selection algorithm, the overall qualities of the individual variants in the list are computed π
The overall quality Q of a variant is the value
Q = round5( qs * qt * qc * ql * qf )
where round5 is a function which rounds a floating point value to 5 decimal places after the point, and where the factors qs, qt, qc, ql, and qf are determined as follows π§
- qs Is the source quality factor in the variant description.
- qt The media type quality factor is 1 if there is no type attribute in the variant description, or if there is no Accept header in the request. Otherwise, it is the quality assigned by the Accept header to the media type in the type attribute.
- Note: If a type is matched by none of the elements of an Accept header, the Accept header assigns the quality factor 0 to that type. π
- qc The charset quality factor is 1 if there is no charset attribute in the variant description, or if there is no Accept-Charset header in the request. Otherwise, the charset quality factor is the quality assigned by the Accept-Charset header to the charset in the charset attribute.
- ql The language quality factor is 1 if there is no language attribute in the variant description, or if there is no Accept-Language header in the request. Otherwise, the language quality factor is the highest quality factor assigned by the Accept-Language header to any one of the languages listed in the language attribute.
- qf The features quality factor is 1 if there is no features attribute in the variant description, or if there is no Accept-Features header in the request. Otherwise, it is the quality degradation factor for the features attribute, see section 6.4 of [2] π
As an example, if a variant list contains the variant description
{"paper.html.en" 0.7 {type text/html} {language fr}}
and the request contains the Accept- headers
Accept: text/html:q=1.0, */*:q=0.8
Accept-Language: en;q=1.0, fr;q=0.5
the remote variant selection algorithm computes an overall quality for the variant like this π
{"paper.html.fr" 0.7 {type text/html} {language fr}}
| | |
| | |
V V V
round5 ( 0.7 * 1.0 * 0.5 ) = 0.35000
With the above Accept- headers, the complete variant list
{"paper.html.en" 0.9 {type text/html} {language en}},
{"paper.html.fr" 0.7 {type text/html} {language fr}},
{"paper.ps.en" 1.0 {type application/postscript} {language en}}
would yield the following computations π₯
round5 ( qs * qt * qc * ql * qf ) = Q
--- --- --- --- --- -------
paper.html.en: 0.9 * 1.0 * 1.0 * 1.0 * 1.0 = 0.90000
paper.html.fr: 0.7 * 1.0 * 1.0 * 0.5 * 1.0 = 0.35000
paper.ps.en: 1.0 * 0.8 * 1.0 * 1.0 * 1.0 = 0.80000
3.4. Definite and speculative quality values π
A computed overall quality value can be either definite or speculative. An overall quality value is definite if it was computed without using any wildcard characters '*' in the Accept- headers, and without the need to use the absence of a particular Accept- header. An overall quality value is speculative otherwise β¨
As an example, in the previous section, the quality values of paper.html.en and paper.html.fr are definite, and the quality value of paper.ps.en is speculative because the type application/postscript was matched to the range /. π«Ά
Definiteness can be defined more formally as follows. An overall quality value Q is definite if the same quality value Q can be computed after the request message is changed in the following way π§
- If an Accept, Accept-Charset, Accept-Language, or Accept-Features header is missing from the request, add this header with an empty field.
- Delete any media ranges containing a wildcard character '' from the Accept header. Delete any wildcard '' from the Accept-Charset, Accept-Language, and Accept-Features headers.
As another example, the overall quality factor for the variant
{"blah.html" 1 {language en-gb} {features blebber [x y]}}
is 1 and definite with the Accept- headers
Accept-Language: en-gb, fr
Accept-Features: blebber, x, !y, *
and
Accept-Language: en, fr
Accept-Features: blebber, x, *
The overall quality factor is still 1, but speculative, with the Accept- headers
Accept-language: en-gb, fr
Accept-Features: blebber, !y, *
and
Accept-Language: fr, *
Accept-Features: blebber, x, !y, *
To be continued in part 2! ππ
3.5 Determining the result β¨
okay so the best variant is the one with the highest overall quality value π. if a bunch of variants are tied for that top score, the first one in the list wins π
the end result of the remote variant selection algorithm is Choice_response only if ALL of these are true π«Ά
- a. the overall quality value of the best variant is greater than 0
- b. the overall quality value of the best variant is a definite quality value
- c. the variant resource is a neighbor of the negotiable resource. this last one is there so a security-related restriction on generating choice responses gets met, see sections 10.2 and 14.2 of [2] π
if any of that isn't true, the end result is List_response πΈ
the definiteness rule is lowkey a game changer for Accept- headers π for example, it makes the remote algorithm read
Accept: image/gif;q=0.9, */*;q=1.0
as:
'I accept image/gif with a quality of 0.9, and assign quality
factors up to 1.0 to other media types. If this information is
insufficient to make a choice on my behalf, do not make a choice
but send the list of variants'.
without that rule, it would have been read as:
'I accept image/gif with a quality of 0.9, and all other media
types with a quality of 1.0'.
so the definiteness rule really changes what the header means π
4. Use of the algorithm π¦
this section is all about how user agents can use the remote algorithm in an optimal way. heads up, this section is NOT normative, it's just here for informational purposes π§
4.1 Using quality factors to rank preferences π
with quality factors, a user agent can rank the items inside one Accept- header, AND it can say which Accept- headers matter more than others π₯ say we have this variant list:
{"paper.english" 1.0 {language en} {charset ISO-8859-1}},
{"paper.greek" 1.0 {language el} {charset ISO-8859-7}}
now the user likes "el" more than "en", but the user agent can render "ISO-8859-1" at a higher quality than "ISO-8859-7". if the Accept- headers are:
Accept-Language: gr, en;q=0.8
Accept-Charset: ISO-8859-1, ISO-8859-7;q=0.6, *
then the remote variant selection algorithm picks the English variant, because it has the least overall quality degradation π¬π§ but if the headers are:
Accept-Language: gr, en;q=0.8
Accept-Charset: ISO-8859-1, ISO-8859-7;q=0.95, *
then the algorithm picks the Greek variant π¬π·
basically, the Accept- header with the biggest spread between its quality factors gets the highest precedence β¨ and if a user agent lets the user set quality factors for some headers while others are hard-coded, it should use a low spread on the hard-coded factors and a high spread on the user-supplied ones. that way the user's settings win over the built-in ones π
4.2 Construction of short requests π
on a transparently negotiated resource, a user agent doesn't need to send a super long Accept- header listing every single capability to get good results π instead of sending this whole thing:
Accept: image/gif;q=0.9, image/jpeg;q=0.8, image/png;q=1.0,
image/tiff;q=0.5, image/ief;q=0.5, image/x-xbitmap;q=0.8,
application/plugin1;q=1.0, application/plugin2;q=0.9
the user agent can just send:
Accept: image/gif;q=0.9, */*;q=1.0
and it won't risk getting a choice response with some inferior image/tiff variant π for example, with this variant list:
{"x.gif" 1.0 {type image/gif}}, {"x.tiff" 1.0 {type image/tiff}},
the remote algorithm computes a definite overall quality of 0.9 for x.gif and a speculative overall quality value of 1.0 for x.tiff. since the best variant has a speculative quality value, the algorithm won't choose x.tiff. it returns a list response instead, and then the user agent's own selection algorithm correctly picks x.gif π₯Ή the end result is the same as if the long header had been sent. iconic π
so user agents can tune how long their Accept- headers are, trading off between how fast the first request goes out and the chance that the remote algorithm has enough info to skip a second request β
4.2.1 Collapsing Accept- header elements π
this section covers how a long Accept- header that lists every capability and preference can be made shorter, safely π«Ά the remote variant selection algorithm is built so that it is always safe to shorten an Accept or Accept-Charset header by taking two header elements A;q=f and B;q=g and replacing them with one element P;q=m. here P is a wildcard pattern that matches both A and B, and m is the maximum of f and g. some examples:
text/html;q=1.0, text/plain;q=0.8 --> text/*;q=1.0
image/*;q=0.8, application/*;q=0.7 --> */*;q=0.8
iso-8859-5;q=1.0, unicode-1-1;q=0.8 --> *;q=1.0
every ;q=1.0 above is optional and can be dropped:
iso-8859-7;q=0.6, * --> *
for Accept-Language, it's safe to collapse all language ranges with the same primary tag into a wildcard:
en-us;q=0.9, en-gb;q=0.7, en;q=0.8, da --> *;q=0.9, da
it's also safe to collapse a language range into a wildcard, or swap it for a wildcard, if its primary tag only shows up once:
*;q=0.9, da --> *
and finally, in the Accept-Features header, every feature expression can be collapsed into a wildcard, or replaced by one:
colordepth!=5, * --> *
4.2.2 Omitting Accept- headers π
according to the HTTP/1.1 specification [1], if the Accept header is completely absent from the request, that's the same as having Accept: */*. so if the Accept header gets collapsed into Accept: */*, a user agent may leave it out entirely π«§ an Accept-Charset, Accept-Language, or Accept-Features header that only contains * may also be omitted.
4.2.3 Dynamically lengthening requests π¦
in general, a user agent that can do transparent content negotiation can send short requests by default β¨ some short Accept- headers could still be included for the sake of existing servers that use HTTP/1.0 style negotiation (see section 4.2 of [2]). for example:
GET /paper HTTP/1.1
Host: x.org
User-Agent: WuxtaWeb/2.4
Negotiate: 1.0
Accept-Language: en, *;q=0.9
if the Accept- headers in a default request like this aren't suitable as input to the remote variant selection algorithm, the user agent can turn the algorithm off by sending Negotiate: trans instead of Negotiate: 1.0 π
ββοΈ
if the user agent finds out, from getting a list or choice response, that a particular origin server has transparently negotiated resources, it could make future requests to that server longer. for example:
GET /paper/chapter1 HTTP/1.1
Host: x.org
User-Agent: WuxtaWeb/2.4
Negotiate: 1.0
Accept: text/html, application/postscript;q=0.8, */*
Accept-Language: en, fr;q=0.5, *;q=0.9
Accept-Features: tables, *
this makes it more likely that the remote variant selection algorithm has enough info to choose on the user agent's behalf, which optimizes the negotiation π§ a good strategy for dynamic extension is to add the media types, languages, charsets, and feature tags mentioned in the variant lists of past responses from that server π
4.3 Differences between the local and the remote algorithm πΈ
a user agent can only optimize content negotiation through the remote algorithm if its local algorithm will generally make the same choice π«Ά if a user agent gets a choice response containing a variant X picked by the remote algorithm, but the local algorithm would have picked Y, the user agent has two options:
- Retrieve Y in a subsequent request. this is sub-optimal, because it takes time π’
- Display X anyway. this is sub-optimal too, because the end result of negotiation now depends on factors that can randomly change π΅ for the next request on the same resource, an intermediate proxy cache could return a list response, which would make the local algorithm choose and retrieve Y instead of X. compared to a stable representation, a representation that randomly switches between X and Y (say, the version with and without frames) has a very low subjective quality for most users π
since both options are unattractive, a user agent should try to avoid this situation altogether β¨ the sections below talk about how.
4.3.1 Avoiding major differences π
if the user agent enables the remote algorithm in this specification, it should generally use a local algorithm that closely resembles the remote algorithm πͺ for example, the algorithm should also use multiplication to combine quality factors. if the user agent combines quality factors by addition, it would be more advantageous to define a new remote variant selection algorithm, with a new major version number, for use by that agent π₯
4.3.2 Working around minor differences π§
even if a local algorithm uses multiplication to combine quality factors, it could use an extended quality formula like this:
Q = round5( qs * qt * qc * ql * qf ) * q_adjust
this lets it account for special interdependencies between dimensions that come from limitations of the user agent. for example, if the user agent for some reason can't handle the iso-8859-7 charset when rendering text/plain documents, the q_adjust factor would be 0 when the text/plain - iso-8859-7 combination is present in the variant description, and 1 otherwise π
by selectively holding back information from the remote variant selection algorithm, the user agent can make sure the remote algorithm never makes a choice when the local q_adjust is less than 1 π for example, to stop the remote algorithm from ever returning a text/plain - iso-8859-7 choice response, the user agent should take care to never produce a request that exactly specifies the quality factors of both text/plain and iso-8859-7. leaving out either factor from a request makes the overall quality value of any text/plain - iso-8859-7 variant speculative, and variants with speculative quality values can never be returned in a choice response π«
in general, if the local q_adjust doesn't equal 1 for a particular combination X - Y - Z, then a remote choice can be prevented by always leaving out at least one of the elements of that combination from the Accept- headers, and adding a suitable wildcard pattern to match the left-out element, if one isn't already there π
5. Security and privacy considerations π
this specification doesn't introduce any security and privacy considerations that aren't already covered in [2] π₯Ί see [2] for a discussion of the privacy risks that come with sending Accept- headers. protect your Accept- headers, bestie π«Άπ
6. Acknowledgments π«Ά
okay so the history here is kinda wild π°οΈ people have been doing HTTP content negotiation since at least 1993, and the authors honestly can't trace where a lot of these ideas came from π so many members of the HTTP working group helped shape the negotiation model in this spec β¨
the authors also wanna thank the people who commented on earlier versions of this doc: Brian Behlendorf, Daniel DuBois, Ted Hardie, Larry Masinter, and Roy T. Fielding π literal legends
7. References π
[1] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., and T. Berners-Lee, "Hypertext Transfer Protocol -- HTTP/1.1", RFC 2068, January 1997. πΈ
[2] Holtman, K., and A. Mutz, "Transparent Content Negotiation in HTTP", RFC 2295, March 1998. π¦
8. Authors' Addresses π
the people who wrote this one, with their contact info:
Koen Holtman
Technische Universiteit Eindhoven
Postbus 513
Kamer HG 6.57
5600 MB Eindhoven (The Netherlands)
EMail: koen@win.tue.nl
Andrew H. Mutz
Hewlett-Packard Company
1501 Page Mill Road 3U-3
Palo Alto CA 94304, USA
Fax: +1 415 857 4691
EMail: mutz@hpl.hp.com
9. Full Copyright Statement βοΈ
this part is legal stuff, so it stays word for word (no vibes changed here, bestie π):
Copyright (C) The Internet Society (1998). All Rights Reserved.
This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns.
This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. π
π¦ where this page comes from
- ietf: rfc2296 1998-03
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms