Skip to content

Range request behavior

Cloudflare can serve HTTP range requests from complete or partial cached files. Origin Range Requests let Cloudflare fetch eligible files from your origin in cache-aligned byte ranges.

Request eligibility

Cloudflare uses the partial-file path only for a GET request that is eligible for caching when the request arrives. The origin response may later prove uncacheable. In that case, Cloudflare can still use origin range fetching, but does not store the response bytes.

HEAD requests and other methods do not use this path.

HEAD requests

A HEAD request containing Range can return 200 OK, 206 Partial Content, 304 Not Modified, or 416 Range Not Satisfiable. A HEAD response never has a body. A 206 Partial Content response includes Content-Range. When Cloudflare serves a complete cached file without Origin Range Requests, a matching If-Range validator can preserve a 206 Partial Content response, while a mismatch returns 200 OK. Cloudflare ignores If-Range for other HEAD request paths.

Client response behavior

Requests without Range

A successful, unconditional GET without Range returns the complete file as 200 OK. On a cold cache miss, the first origin request also omits Range.

If only part of the file is cached, Cloudflare may request the missing bytes from the origin. The client still receives one complete 200 OK response.

One valid range

The following requests return 206 Partial Content when successful:

  • Range: bytes=100-199
  • Range: bytes=100-
  • Range: bytes=-100

Cloudflare shortens an end position that exceeds the file size. A suffix range larger than the file returns the complete file as 206 Partial Content.

Unsatisfiable ranges

Cloudflare returns 416 Range Not Satisfiable for:

  • An empty range, such as bytes=
  • A zero-length suffix, such as bytes=-0
  • Inverted range bounds
  • A range starting at or beyond the end of the file
  • A range against an empty, uncompressed file
  • Overlapping or out-of-order ranges when Origin Range Requests applies

A Cloudflare-generated 416 Range Not Satisfiable response has an empty body. It includes Content-Range: bytes */<FILE_SIZE>.

When Cloudflare serves a complete cached file without Origin Range Requests, it ignores overlapping or out-of-order ranges and normally returns the complete file as 200 OK.

Ignored Range headers

Cloudflare processes the request as a non-range request when:

  • The range syntax cannot be parsed
  • The range unit is not bytes
  • A number is too large to parse
  • The header contains more than 500 ranges, or exactly 500 ranges when Cloudflare serves a complete cached file without Origin Range Requests

This normally returns the complete file as 200 OK. Conditional requests can return 304 Not Modified, and origin errors still apply.

Multiple ranges

When Origin Range Requests applies, between two and 500 valid, ascending, non-overlapping ranges return a multipart 206 Partial Content response. Cloudflare omits individual ranges that cannot be satisfied. The response remains multipart if only one range remains. If no ranges remain, Cloudflare returns 416 Range Not Satisfiable.

When Cloudflare serves a complete cached file without Origin Range Requests, one remaining satisfiable range produces a single-range 206 Partial Content response.

Conditional requests

If-None-Match and If-Modified-Since take precedence over Range. They can produce a 304 Not Modified response.

Otherwise, an If-Range value that exactly matches the cached ETag or Last-Modified value preserves range behavior. A mismatch causes Cloudflare to ignore Range and use the complete-response path.

Decompression

Cloudflare serves a range of a cached file encoded with gzip or Brotli (br) only if the client accepts that encoding. The client's Accept-Encoding header must explicitly name gzip or br without a quality value of 0 (RFC 9110, section 12.4.2 ↗︎ and section 12.5.3 ↗︎). An absent Accept-Encoding header, *, or x-gzip does not qualify. A Brotli range also requires HTTPS, and a Workers subrequest without the brotli_content_encoding compatibility flag does not receive a Brotli range. When these conditions are met, Cloudflare sends 206 Partial Content with the cached Content-Encoding. Per RFC 9110, section 14.1.2 ↗︎ and section 8.4 ↗︎, the byte range counts bytes of the encoded file, not of the decompressed content.

Otherwise, Cloudflare ignores Range and sends the complete file as 200 OK using normal content negotiation. Cloudflare decompresses or recompresses the 200 OK response as needed for the client's Accept-Encoding, or keeps the cached encoding when the client accepts it. Cloudflare always sends the complete 200 OK file for a cached file encoded with Zstandard (zstd) or deflate. HTTP allows a server to ignore Range (RFC 9110, section 14.2 ↗︎).

A cached file without Content-Encoding keeps the range behavior described on this page. So does a file with an encoding Cloudflare does not decompress (any encoding other than gzip, br, zstd, or deflate).

If Cloudflare must decompress a complete encoded response from the origin, it also ignores Range and sends the complete response as 200 OK.

When Cloudflare decompresses or ignores Range for an empty, encoded response, it returns an empty 200 OK, not 416 Range Not Satisfiable.

Origin request behavior

Cloudflare aligns origin range requests to 1 MiB cache boundaries. For example, if a client requests a 1 KiB range, Cloudflare may fetch a 1 MiB range from your origin and return only the requested 1 KiB to the client. Cloudflare may also split one client request into several single-range origin requests. The Range values seen by your origin can differ from the client's header. Consider this behavior when configuring origin logs, request limits, rate limits, or request signing. Cloudflare logs record one entry per client request. The separate range requests that Cloudflare sends to your origin do not appear as their own log entries.

Cloudflare adds Accept-Encoding: identity to every origin request generated by Origin Range Requests. This includes a complete-file GET handled by the feature. It does not disable normal compression between Cloudflare and the client.

Partial response requirements

For Cloudflare to cache an origin 206 Partial Content response, the response must meet these requirements:

Response field Requirement
Content-Encoding The response must be unencoded.
Content-Range Include a concrete range. Its start must match Cloudflare's request. Its end must match the requested end or the end of the file, whichever comes first. Include the complete file size.
Content-Length Include a numeric value equal to the returned interval length.
Transfer-Encoding Omit this header.
ETag Optional. If present, its presence and exact value must remain consistent across responses for the same cached representation.

The complete file size must also remain consistent across responses. Violations can prevent caching or end responses served to the client early.

Test origin range support

To check whether your origin supports range requests, send a range request directly to your origin. A request through a proxied hostname can return 206 Partial Content from Cloudflare even when your origin ignores Range. Cloudflare requests ranges aligned to 1 MiB, so test with the first 1 MiB of a file larger than 1 MiB.

curl https://example.com/large-file.mp4 --connect-to ::<ORIGIN_ADDRESS> --header "Range: bytes=0-1048575" --header "Accept-Encoding: identity" --dump-header - --output /dev/null

Replace <ORIGIN_ADDRESS> with your origin's IP address or hostname. The --connect-to flag routes the request to that address while keeping the Host header as example.com. If your origin uses a Cloudflare Origin CA certificate, add --insecure, because curl does not trust that certificate.

A 206 Partial Content response with Content-Range: bytes 0-1048575/<FILE_SIZE> and Content-Length: 1048576 shows that your origin supports range requests. Check that the response also meets the partial response requirements. A 200 OK response means that your origin ignores Range.

Origin responses that do not honor Range

If the origin ignores a Cloudflare-generated Range header and returns a complete 200 OK, Cloudflare can use the response. Cloudflare must download the complete file and may then return the requested range to the client.

If the origin returns an encoded 206 Partial Content response, Cloudflare does not cache it. Before the client response starts, Cloudflare may send that single response without caching. After the response starts, Cloudflare ends it early, and the client receives fewer bytes than promised.

Other incompatible origin responses during a response assembled from several requests can also end the client response early.

Caching limitations

Origin Range Requests do not make an otherwise ineligible request or response cacheable. Cloudflare checks the maximum cacheable file size against the complete size from Content-Range. Requesting a small range does not bypass this limit.

Changing the Origin Range Requests setting does not change the cache key or purge cached files. Cloudflare records which byte ranges of a file are cached alongside the file. Files cached in full remain usable either way. After you turn the setting off, Cloudflare stops serving files it holds only in part. The next request for such a file fetches the complete file again and replaces the partial copy. After you turn the setting on, a file already cached with a Content-Encoding keeps that encoding, and range requests for it follow Decompression. To fetch it unencoded with Origin Range Requests, purge it.

Origin Range Requests are not supported with Cache Reserve.

Uncached range requests

If caching is bypassed or the request is not eligible for caching, Cloudflare forwards the client's Range header to your origin. For GET requests over HTTPS (RFC 9110, section 14.2 ↗︎ defines Range for GET only), Cloudflare also forwards the client's own Accept-Encoding header instead of its default header. Your origin can then return a range in an encoding the client accepts. Over HTTP, Cloudflare continues to send Accept-Encoding: gzip, and non-GET requests (such as HEAD) keep Cloudflare's default header.

Cloudflare passes a byte-range 206 Partial Content response (bytes unit) from your origin to the client without decoding it, even if a Compression Rule applies. Cloudflare also does not compress a 206 Partial Content response. Changing the content encoding of a byte range would invalidate its Content-Range offsets and total length (RFC 9110, section 14.1.2 ↗︎ and section 14.4 ↗︎). Partial responses that use a non-bytes range unit are still decoded as usual.

The forwarded Accept-Encoding header has these exceptions:

  • No header from the client: Your origin receives no Accept-Encoding header, or an empty one on Orange-to-Orange requests.
  • Shared dictionaries: Cloudflare removes dcb and dcz unless shared dictionaries are enabled on the zone and the request includes a valid Available-Dictionary header (RFC 9842, section 2.2 ↗︎ and section 6.1 ↗︎). If removing those encodings leaves the header empty, Cloudflare sends an empty Accept-Encoding header rather than omitting it.
  • Workers subrequests: Subrequests from Workers without the brotli_content_encoding compatibility flag send Accept-Encoding: gzip instead of the client's header so the origin does not return a Brotli range the Worker cannot decode.
  • Origin Range Requests: Requests handled by Origin Range Requests send Accept-Encoding: identity, as described in Origin request behavior. On a zone with Origin Range Requests enabled, requests that bypass caching or are ineligible for caching are not handled by the feature and still forward the client's Accept-Encoding.

Under RFC 9110, section 12.5.3 ↗︎, omitting Accept-Encoding means any content coding is acceptable, whereas an empty Accept-Encoding header means the client accepts no encoding. Your origin should answer an empty Accept-Encoding header with an unencoded response, not 406 Not Acceptable.

Was this helpful?