Accept-Encoding - HTTP | MDN

archived 1 Jun 2017 05:48:59 UTC
Your Search Results

    Accept-Encoding

    The Accept-Encoding request HTTP header advertises which content encoding, usually a compression algorithm, the client is able to understand. Using content negotiation, the server selects one of the proposals, uses it and informs the client of its choice with the Content-Encoding response header.
    Even if both the client and the server supports the same compression algorithms, the server may choose not to compress the body of a response, if the identity value is also acceptable. Two common cases lead to this:
    • The data to be sent is already compressed and a second compression won't lead to smaller data to be transmitted. This may the case with some image formats;
    • The server is overloaded and cannot afford the computational overhead induced by the compression requirement. Typically, Microsoft recommends not to compress if a server use more than 80 % of its computational power.
    As long as the identity value, meaning no encoding, is not explicitly forbidden, by an identity;q=0 or a *;q=0 without another explicitly set value for identity, the server must never send back a 406 Not Acceptable error.
    Notes:
    • Two others content encoding, bzip and bzip2, are sometimes used, though not standard. They implement the algorithm used by these two UNIX programs. Note that the first one was discontinued due to patent licensing problems.
    Header type Request header
    Forbidden header name yes

    Syntax

    Accept-Encoding: gzip
    Accept-Encoding: compress
    Accept-Encoding: deflate
    Accept-Encoding: br
    Accept-Encoding: identity
    Accept-Encoding: *
    
    // Multiple algorithms, weighted with the quality value syntax:
    Accept-Encoding: deflate, gzip;q=1.0, *;q=0.5

    Directives

    gzip
    A compression format using the Lempel-Ziv coding (LZ77), with a 32-bit CRC.
    compress
    A compression format using the Lempel-Ziv-Welch (LZW) algorithm.
    deflate
    A compression format using the zlib structure, with the deflate compression algorithm.
    br
    A compression format using the Brotli algorithm.
    identity
    Indicates the identity function (i.e. no compression, nor modification). This value is always considered as acceptable, even if not present.
    *
    Matches any content encoding not already listed in the header. This is the default value if the header is not present. It doesn't mean that any algorithm is supported; merely that no preference is expressed.
    ;q= (qvalues weighting)
    Any value is placed in an order of preference expressed using a relative quality values called weight.

    Examples

    Accept-Encoding: gzip
    
    Accept-Encoding: gzip, compress, br
    
    Accept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1

    Specifications

    Specification Title
    RFC 7231, section 5.3.4: Accept-Encoding Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context

    Browser compatibility

    The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
    Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
    Accept-Encoding(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)
    Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
    Accept-Encoding(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)(Yes)

    See also

    Document Tags and Contributors

     Contributors to this page: sideshowbarker, lshearer, fscholz, teoli
     Last updated by: sideshowbarker,

    Thanks! Please check your inbox to confirm your subscription.

    If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.
    See also
    1. HTTP
    2. Guides:
    3. Resources and URIs
      1. Identifying resources on the Web
      2. Data URIs
      3. Introduction to MIME Types
      4. Complete list of MIME Types
      5. Choosing between www and non-www URLs
    4. Basics of HTTP
      1. Overview of HTTP
      2. Evolution of HTTP
      3. HTTP Messages
      4. A typical HTTP session
      5. Connection management in HTTP/1.x
    5. HTTP security
      1. Content Security Policy (CSP)
      2. HTTP Public Key Pinning (HPKP)
      3. HTTP Strict Transport Security (HSTS)
      4. Cookie security
      5. X-Content-Type-Options
      6. X-Frame-Options
      7. X-XSS-Protection
      8. Mozilla web security guidelines
      9. Mozilla Observatory
    6. HTTP access control (CORS)
    7. HTTP authentication
    8. HTTP caching
    9. HTTP compression
    10. HTTP conditional requests
    11. HTTP content negotiation
    12. HTTP cookies
    13. HTTP range requests
    14. HTTP redirects
    15. HTTP specifications
    16. References:
    17. HTTP headers
      1. Accept
      2. Accept-Charset
      3. Accept-Encoding
      4. Accept-Language
      5. Accept-Ranges
      6. Access-Control-Allow-Credentials
      7. Access-Control-Allow-Headers
      8. Access-Control-Allow-Methods
      9. Access-Control-Allow-Origin
      10. Access-Control-Expose-Headers
      11. Access-Control-Max-Age
      12. Access-Control-Request-Headers
      13. Access-Control-Request-Method
      14. Age
      15. Allow
      16. Authorization
      17. Cache-Control
      18. Connection
      19. Content-Disposition
      20. Content-Encoding
      21. Content-Language
      22. Content-Length
      23. Content-Location
      24. Content-Range
      25. Content-Security-Policy
      26. Content-Security-Policy-Report-Only
      27. Content-Type
      28. Cookie
      29. Cookie2
      30. DNT
      31. Date
      32. ETag
      33. Expect
      34. Expires
      35. Forwarded
      36. From
      37. Host
      38. If-Match
      39. If-Modified-Since
      40. If-None-Match
      41. If-Range
      42. If-Unmodified-Since
      43. Keep-Alive
      44. Large-Allocation
      45. Last-Modified
      46. Location
      47. Origin
      48. Pragma
      49. Proxy-Authenticate
      50. Proxy-Authorization
      51. Public-Key-Pins
      52. Public-Key-Pins-Report-Only
      53. Range
      54. Referer
      55. Referrer-Policy
      56. Retry-After
      57. Server
      58. Set-Cookie
      59. Set-Cookie2
      60. Strict-Transport-Security
      61. TE
      62. Tk
      63. Trailer
      64. Transfer-Encoding
      65. Upgrade-Insecure-Requests
      66. User-Agent
      67. Vary
      68. Via
      69. WWW-Authenticate
      70. Warning
      71. X-Content-Type-Options
      72. X-DNS-Prefetch-Control
      73. X-Forwarded-For
      74. X-Forwarded-Host
      75. X-Forwarded-Proto
      76. X-Frame-Options
      77. X-XSS-Protection
    18. HTTP request methods
      1. CONNECT
      2. DELETE
      3. GET
      4. HEAD
      5. OPTIONS
      6. PATCH
      7. POST
      8. PUT
    19. HTTP response status codes
      1. 100 Continue
      2. 101 Switching Protocol
      3. 200 OK
      4. 201 Created
      5. 202 Accepted
      6. 203 Non-Authoritative Information
      7. 204 No Content
      8. 205 Reset Content
      9. 206 Partial Content
      10. 300 Multiple Choices
      11. 301 Moved Permanently
      12. 302 Found
      13. 303 See Other
      14. 304 Not Modified
      15. 307 Temporary Redirect
      16. 308 Permanent Redirect
      17. 400 Bad Request
      18. 401 Unauthorized
      19. 403 Forbidden
      20. 404 Not Found
      21. 405 Method Not Allowed
      22. 406 Not Acceptable
      23. 407 Proxy Authentication Required
      24. 408 Request Timeout
      25. 409 Conflict
      26. 410 Gone
      27. 411 Length Required
      28. 412 Precondition Failed
      29. 413 Payload Too Large
      30. 414 URI Too Long
      31. 415 Unsupported Media Type
      32. 416 Range Not Satisfiable
      33. 417 Expectation Failed
      34. 426 Upgrade Required
      35. 428 Precondition Required
      36. 429 Too Many Requests
      37. 431 Request Header Fields Too Large
      38. 451 Unavailable For Legal Reasons
      39. 500 Internal Server Error
      40. 501 Not Implemented
      41. 502 Bad Gateway
      42. 503 Service Unavailable
      43. 504 Gateway Timeout
      44. 505 HTTP Version Not Supported
      45. 511 Network Authentication Required
    20. CSP directives
      1. CSP: base-uri
      2. CSP: block-all-mixed-content
      3. CSP: child-src
      4. CSP: connect-src
      5. CSP: default-src
      6. CSP: font-src
      7. CSP: form-action
      8. CSP: frame-ancestors
      9. CSP: frame-src
      10. CSP: img-src
      11. CSP: manifest-src
      12. CSP: media-src
      13. CSP: object-src
      14. CSP: plugin-types
      15. CSP: referrer
      16. CSP: report-uri
      17. CSP: require-sri-for
      18. CSP: sandbox
      19. CSP: script-src
      20. CSP: style-src
      21. CSP: upgrade-insecure-requests
      22. CSP: worker-src
    0%
    10%
    20%
    30%
    40%
    50%
    60%
    70%
    80%
    90%
    100%