HTTP status code 206 “Partial Content” indicates that the server has successfully processed a partial GET request and returned the requested data range to the client. This status is commonly used for implementing resume functionality for interrupted downloads or for downloading large files in chunks. When a client sends a GET request with the Range header, the server responds with the corresponding portion of the content and includes the Content-Range field in the response header to indicate the range of content being returned.
Example Use Case
For instance, if a client requests a specific part of a video file, the server can respond with a 206 status code and send only the requested video segment. This approach reduces the amount of data transmitted over the network and improves efficiency.
Key Considerations When Using 206 Partial Content:
- The client request must include the Range header, specifying the desired content range.
- The server response must contain the Content-Range header, describing the range of content being returned.
- If the response includes a Content-Length header, its value should match the number of bytes being returned.
- The server may also include the Accept-Ranges header, indicating that byte ranges can be requested.
Additionally, if the client uses the If-Range header to request partial content, the server will verify whether the resource has been modified and then decide whether to return a 206 Partial Content or a 200 OK status code.
Common Applications of 206 Partial Content
The 206 status code is frequently used for scenarios such as segmented loading of video and audio streams, downloading large files, and lazy loading of images.