httpwg / http-core

Core HTTP Specifications
https://httpwg.org/http-core/
467 stars 43 forks source link

`Vary: Range` in responses to range requests: Necessary? #1055

Closed mpdude closed 2 years ago

mpdude commented 2 years ago

Dear httpwg,

congratulations on completing RFC 9110 and thank you for your efforts put into it! You've added a dedicated section for Range Requests, and I have a question on that.

In section 15.3.7, it says:

A server that generates a 206 response MUST generate the following header fields, in addition to those required in the subsections below, if the field would have been sent in a 200 (OK) response to the same request: Date, Cache-Control, ETag, Expires, Content-Location, and Vary.

Assume I have a response with code 200 that is either heuristically cacheable or has an explicit cache-control header, but does not contain a Vary header.

What should happen if the client performs the same request again, but this time includes a Range header?

Should the 206 contain Vary: Range, since the body of the response depends on (and changes with) this value? Or are caches supposed to know about the special semantics of 206 themselves and take Range into account accordingly?

royfielding commented 2 years ago

The 206 would not contain a Vary: Range because the selected representation in not influenced by Range -- only the content extracted from that representation. And, yes, caches have to know that in order to make use of 206 responses.

mpdude commented 2 years ago

Oh, I was not aware of that distinction between selecting a representation and the content extracted from it. A good opportunity to go back and re-read the spec :-).

I also overlooked that, apart from other requirements that must be met, caches must understand the particular response codes in order to be allowed to cache them, not just cache "any 2xx code that is cacheable". And already RFC 2616 mentioned that 206 responses must not be cached unless Range and Content-Range are understood.

Thank you!