Skip to content

Accept-Encoding

Description

The Accept-Encoding request header is an HTTP header used by clients (such as web browsers) to indicate the content encoding (compression algorithms) they support. This allows servers to return responses in a compressed format, reducing the size of transferred data and improving load times.

Compression is an essential part of web performance optimization, as it minimizes bandwidth usage and speeds up content delivery. Common encoding formats include gzip, deflate, and br (Brotli). The server processes this header and selects a supported encoding before responding with the Content-Encoding response header.

Syntax

The Accept-Encoding header follows this syntax:

Accept-Encoding: <encoding1>, <encoding2>, ...

The <encoding> values can include:

  • gzip – Gzip compression
  • deflate – Zlib-based compression
  • br – Brotli compression (used mainly with HTTPS)
  • identity – No compression (default behavior)
  • * – Any available encoding supported by the server

Examples

Basic Usage in HTTP Requests

When a client supports multiple compression formats, it can send:

GET /resource HTTP/2
Host: example.com
Accept-Encoding: gzip, deflate, br

If the client only supports gzip, it will send:

GET /resource HTTP/2
Host: example.com
Accept-Encoding: gzip

Server Response Example

The server inspects the Accept-Encoding header and responds with a compressed version of the resource if supported:

HTTP/2 200 OK
Content-Encoding: gzip

Summary

The Accept-Encoding request header is a crucial component of modern web performance, allowing clients to request compressed content and reduce data transfer sizes. By leveraging this header, servers can improve page load times and optimize bandwidth usage. Proper implementation of content encoding enhances user experience and overall web efficiency.