'Can Content-Range header be sent in a HTTP 200 OK Response
My caching server refuses to cache a 200 OK response when it has a Content-Range Header. This was the RFC2616-compliant implementation.
However, a requirement came to cache the 200 OK response even if it has the Content-Range header. Is that allowed or does it violate the RFC-spec?
Solution 1:[1]
According to the MDN docs for Range:
The server can also ignore the
Rangeheader and return the whole document with a 200 status code.
Similarly, the MDN docs for range requests state under Partial request responses:
- In case of no support of range requests, the 200 OK status is sent back from a server.
In other words, the browser can assume that the server does not support partial responses if it receives a 200 in response to a Range header. At the moment, Chrome does just this. Even if you send the entire document back, if Chrome receives a 200 when it requests part of a video, the playback bar/seekbar does not work.
As to whether the Content-Range is actually allowed, I haven't found any documentation yet. From what I understand, the Content-Range header makes no sense if you send a 200 in response to a Range header as you are supposed to send the entire file. In other words, it can be ignored; it is only meaningful with a 206.
To answer your other question, you can therefore cache the 200 regardless of whether Content-Range is present. A 206 with Content-Range may also be cached:
A 206 response is cacheable by default; i.e., unless otherwise indicated by explicit cache controls (see Section 4.2.2 of [RFC7234]).
-- last paragraph in Section 4.1 of RFC 7233.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
