1. HTTP (Hypertext Transfer Protocol)

  1. HTTP Headers

  1. If-Range
    1. Usage in requests
      1. Writing requests (clients)
      2. Reading requests (servers)
    2. Overview table
    3. Syntax
      1. Implementations
    4. History

If-Range

The "If-Range" header field in a request indicates that the Range header should only be considered if the document has not been modified since the specified Etag or Last-Modified date.

It is used when resuming downloads, where the user-agent has a portion of a document, and wants the rest. In the event that the server's copy of the download has changed, this header asks the server to respond with the entire document.

By using If-Range instead of If-Match, clients can avoid issuing a second request in response to 304 (Not Modified)

Usage in requests

Writing requests (clients)

Use the If-Range header in situations where a user-agent has a fraction of a download, and is making a request for additional parts. For example, if a user has paused a download, then resumes it. The resumed download will be a Range request, and should include If-range to ensure the download contents have not changed.

The If-Range header must accompany a Range request-header, clients must not send an If-Range header outside of a Range request.

For details on using the If-Range header in making a request, see Resumable Downloads with HTTP Range.

Reading requests (servers)

Requests with If-Range must be accompanied by a Range header; if the request is missing it, the server may ignore If-Range, or may return 400 (Client Error) to let the client know it's possibly trying to do something that doesn't make sense.

To determine which format the value is in, you only need to examine the first three characters:

If the If-Range value begins with W/" (case-sensitive) or ", then the value is an ETag; and is tested like If-Match.

Values that begin with three characters of the day of the week, /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ (case-sensitive), are HTTP dates, and is tested like If-Unmodified-Since.

If the value could not be parsed, then treat it as a test failure, or return 400 (Client Error); since ignoring If-Match but processing Match could corrupt the client's reassembled document.

If the condition tests true, then process the Range header normally. If the test fails, then the document on the server has been changed since the client's copy, so the Range header must be ignored; the entire document is sent in response.

Overview table

Name
If-Range
Description
Makes the Range header conditional on the document being unmodified since the specified revision.
Direction
Request
Specification
RFC 9110: HTTP Semantics §13.1.5. If-Range

Syntax

If-Range = entity-tag / HTTP-date

Implementations

History

  1. 1999-06: RFC 2616 §14.27. If-Range
  2. 2014-06: RFC 7233: Hypertext Transfer Protocol (HTTP/1.1): Range Requests §3.2. If-Range
  3. 2022-06: RFC 9110 §13.1.5. If-Range