Using the HTTP Range Header with a range specifier other than bytes? Using the HTTP Range Header with a range specifier other than bytes? ajax ajax

Using the HTTP Range Header with a range specifier other than bytes?


Absolutely - you are free to specify any range units you like.

From RFC 2616:

3.12 Range Units

HTTP/1.1 allows a client to request that only part (a range of) the
response entity be included within the response. HTTP/1.1 uses range units in the Range (section 14.35) and Content-Range (section 14.16)
header fields. An entity can be broken down into subranges according to various structural units.

  range-unit       = bytes-unit | other-range-unit  bytes-unit       = "bytes"  other-range-unit = token

The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1
implementations MAY ignore ranges specified using other units.

The key piece is the last paragraph. Really what it's saying is that when they wrote the spec for HTTP/1.1, they only outlined the "bytes" token. But, as you can see from the 'other-range-unit' bit, you are free to come up with your own token specifiers.

Coming up with your own Range specifiers does mean that you have to have control over the client and server code that uses that specifier. So, if you own the backend piece that exposes the "/document/content/http-range-question" URI, you are good to go; presumably you're using a modern web framework that lets you inspect the request headers coming in. You could then look at the Range values to perform the backing query correctly.

Furthermore, if you control the AJAX code that makes requests to the backend, you should be able to set the Range header yourself.

However, there is a potential downside which you anticipate in your question: the potential to break caching. If you are using a custom Range unit, any caches between your client and the origin servers "MAY ignore ranges specified using [units other than 'bytes']". So for example, if you had a Squid/Varnish cache between the front and backend, there's no guarantee that the results you're hoping for will be served from the cache!

You might also consider an alternative implementation where, rather than using a query string, you make the page a "parameter" of the URI; e.g.: /document/content/http-range-question/page/1. This would likely be a little more work for you server-side, but it's HTTP/1.1 compliant and caches should treat it properly.

Hope this helps.


HTTP Range is typically used for recovering interrupted downloads without starting from the beginning.

What you're trying to do would be better handled by OAI-ORE, which allows you to define relationships between multiple documents. (alternative formats, components of the whole, etc)

Unfortunately, it's a relatively new metadata format, and I don't know of any web browsers that ship with native support.


bytes is the only unit supported by HTTP 1.1 Specification.