---
title: "IfRange"
source: "https://github.com/remix-run/remix/blob/8905f3943706e1f53696ab83e70a84873cabfc90/packages/headers/src/lib/if-range.ts#L19"
---

# IfRange

## Summary

The value of an `If-Range` HTTP header.

The `If-Range` header can contain either an entity tag (ETag) or an HTTP date.

[MDN `If-Range` Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range)

[HTTP Semantics Specification](https://www.rfc-editor.org/rfc/rfc9110.html#section-13.1.5)

## Signature

```ts
class IfRange {
  constructor(init: string | Date): IfRange

  // Properties
  value: string

  // Methods
  matches(resource: { etag?: string | null; lastModified?: number | Date | null }): boolean
  toString(): string
  from(value: string | Date | null): IfRange
}

```

## Properties

### `value`

Raw header value, either an entity tag or an HTTP date.

## Methods

### `matches(resource: { etag?: string | null; lastModified?: number | Date | null }): boolean`

Checks if the `If-Range` condition is satisfied for the current resource state.

This method always returns `true` if the `If-Range` header is not present,
meaning the range request should proceed unconditionally.
Empty values also return `true` for compatibility. Other malformed values return `false`.

The `If-Range` header can contain either:
- An HTTP date (RFC 7231 IMF-fixdate format)
- An entity tag (ETag)

When comparing ETags, only quoted strong entity tags are matched as per RFC 9110.
Weak entity tags (prefixed with `W/`) are never considered a match.

#### Parameters

##### `resource`

The current resource state to compare against

### `toString(): string`

Returns the string representation of the header value.



### `from(value: string | Date | null): IfRange`

Parse an If-Range header value.

#### Parameters

##### `value`

The header value (string, Date, or null)