How to make a Webapi based project return gzipped json.

If you do have access to change applicationHost.config, you can enable GZip compression for JSON responses by adding the appropriate mime type to httpCompression -> dynamicTypes

The ApplicationHost.config file exists in the following directory  C:\Windows\System32\inetsrv\config

 

<httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">

<scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />

<dynamicTypes> ...

<!-- compress JSON responses from Web API -->

<add mimeType="application/json" enabled="true" /> ...

</dynamicTypes>

<staticTypes> ... </staticTypes>

</httpCompression>

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>