If-Range Header

Table of Content

The If-Range HTTP request header makes a range request conditional by allowing it to be issued only if the target resource has not been modified after the time specified. This functionality enables efficient updates of cached information with a minimum amount of transaction overhead. It is particularly useful for large resources that might undergo updates during a series of GET range requests.

Syntax

If-Range: "<etag>"
If-Range: <http-date>

Directives

The If-Range header uses either an ETag or a date as a directive:

  • <etag> - An entity tag uniquely representing the requested resource.
  • <http-date> - The date compares to the Last-Modified date of the resource.

Examples

Here are examples of how to use the If-Range header:

GET /file HTTP/1.1
Host: www.example.com
Range: bytes=500-999
If-Range: "737060cd8c284d8af7ad3082f209582d"

In this example, if the ETag hasn't changed, the server will return bytes 500-999 of the document. Otherwise, it will return the entire document.

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Supported
Opera Supported
Edge Supported

How to modify If-Range header

ModHeader is a Chrome extension that can modify HTTP request headers. You can use ModHeader to alter the If-Range header for specific purposes.

Here's how to use it:

  1. Install the ModHeader extension from the Chrome web store.
  2. Click on the ModHeader icon in your browser toolbar to open it.
  3. In the 'Request Headers' section, click on 'Add'.
  4. Fill the 'Name' field with 'If-Range'.
  5. Fill the 'Value' field with your desired '<etag>' value or '<http-date>'.
  6. Now, all your requests will use this If-Range header.

This can be particularly useful when you are testing your website's performance and caching mechanisms, ensuring that they work optimally with the If-Range header.