Skip to content

Web API Compression

The Web API supports HTTP compression. Compression is an easy and effective way to reduce the payload size and increase the speed of communication between a client and the Web API.

Two common compression schemes used on the web are GZip and Deflate. Both of these compression schemes are supported in the Web API. The client must use the Accept-Encoding header to request a compresed response, e.g.:

Accept-Encoding: gzip

If compressed, the response will include a Content-Encoding header and a Content-Length header, e.g.:

Content-Encoding: gzip
...
Content-Length: 6748

The lower limit for compression of the response body is configurable in the web.config file. For example, the below setting will make the Web API skip compression for any request/response that is smaller than 1024 bytes (1 kB).

<setting name="CompressionThresshold" serializeAs="String">
    <value>1024</value>
</setting>