How to Disable 206 Partial Content Responses on Nginx

While you download a PDF via google chrome, you will receive a 206 status response code from the server. It means your that client is making a conditional GET request appending a range header.
You can disable the range header while making the request or using a different browser.

The HTTP 2xx class of status codes indicates the action requested by the client was received, and processed successfully. HTTP/1.1 200 OK is the standard response for successful HTTP requests. When you type in the browser you will get this status code. The HTTP/1.1 206 status code allows the client to grab only part of the resource by sending a range header. This is useful for:

  • Understanding http headers and protocol.
  • Troubleshooting network problems.
  • Troubleshooting large download problems.
  • Troubleshooting CDN and origin HTTP server problems.
  • Test resuming interrupted downloads using tools like lftp or wget or telnet.
  • Test and split a large file size into multiple simultaneous streams i.e. download a large file in parts.

In this article I will show how to disable 206 partial content response on nginx.

Disable 206 Partial Content Responses on Nginx

Find out If HTTP 206 is supported not.

You need to find file size and whether remote server support HTTP 206 requests or not. Use the curl command to see HTTP header for any resources. Type the following curl command and send a HEAD request for the url:

# curl -I

You will get some output like below:

HTTP/1.1 200 OK
Date: Tue, 26 Jun 2018 04:53:28 GMT
Content-Type: image/jpeg
Content-Length: 75834
Connection: keep-alive
Set-Cookie: __cfduid=d6b4bb54af8bab361f2ac2a75f0ae63a81529988808; expires=Wed, 26-Jun-19 04:53:28 GMT; path=/;; HttpOnly
ETag: "1041434115"
Last-Modified: Fri, 27 Apr 2018 07:14:06 GMT
Expires: Fri, 27 Jul 2018 04:53:28 GMT
Cache-Control: public, max-age=2678400
CF-Cache-Status: HIT
Accept-Ranges: bytes
Expect-CT: max-age=604800, report-uri=""
Server: cloudflare
CF-RAY: 430d120468297002-SIN

The following two headers gives out information about this image file:

  • Accept-Ranges: bytes – The Accept-Ranges header indicate that the server accept range requests for a resource. The unit used by the remote web servers is in bytes. This header tell us that either server support download resume or downloading files in smaller parts simultaneously so that download manager applications can speed up download for you. The Accept-Ranges: none response header indicate that the download is not resumable.
  1. Content-Length: 36907 – The Content-Length header indicates the size of the entity-body i.e. the size of the actual image file is 36907 bytes (37K).

Now edit the nginx conf file to disable the Accept-Ranges header.

location / {
    max_ranges 0;
    root html;
    index index.html index.htm;

Set max_ranges 0 to disable the Accept-Ranges header.

Now restart the nginx server.

# service nginx restart

Now verify it using curl command:

[root@app01 /]# curl -I
HTTP/1.1 200 OK
Date: Tue, 26 Jun 2018 04:55:32 GMT
Server: Apache/2.2.15 (CentOS)
Last-Modified: Fri, 27 Apr 2018 07:14:06 GMT
ETag: "501edd-1283a-56acf3fe9a052"
Accept-Ranges: none
Content-Length: 75834
Connection: close
Content-Type: image/jpeg

As you can see Accept-Ranges is showing none.

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author


Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment