I have a WCF web service based on JSON and POST method which have a function called website returning a JSON with more 2KB content. This service has more than 10K requests per second. So, I have lots of textual data to be passed via network and I/O. I think I can reduce this volume of data by compressing the response automatically. I know that by setting a header in client side for accepting zipped content, the client can notify the server that compressed content is acceptable. But how the server can send compressed content?
I have read this link, and implement it. But it works only for SOAP which is xml-based, not JSON. I mean that this configuration:
<customBinding>
<binding name="BinaryCompressionBinding">
<binaryMessageEncoding compressionFormat="GZip"/>
<httpTransport />
</binding>
</customBinding>
can not work with JSON because we have to use binaryMessageEncoding, where as JSON needs webMessageEncoding and it does not support compressionFormat.
Also, IIS dynamic compression can not help me too. I have added markup it needs to compress JSON.
Update: This is my applicationhost.config:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="0"> <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> <dynamicTypes> <add mimeType="application/json" enabled="true" /> <add mimeType="application/json; charset=utf-8" enabled="true" /> </dynamicTypes> </httpCompression>