Tag Archives: wcf

WCF RIA gzip compression of response

I was trying to enable gzip compression of my WCF RIA traffic to decrease the amount of data that is send between the client and server and improve performance.

Note: I used Fiddler2 to determine if the responses were actually compressed or not.

There is a lot of Q&A about this topic on the web, but nobody had a straight solution for me. Some posts refered to old versions of IIS or used 3rd party modules.

I was looking for a solution that will work from with IIS7.5 without installing any 3rd party modules.

Here is how I made it work.

Lets first install the necessary modules: the Dynamic and Static Content Compression modules:

How-to enable GZIP compression for normal traffic:
On Windows 7:
“Start->Control Panel->Programs and features” and click on “Turn Windows features on or off”.
Then enable:
“Dynamic Content Compression” and “Static Content Compression” in “Internet Information Services->World Wide Webservices->Performance Features” and press “Ok”.

Now your ‘normal’ HTTP responses are automatically compressed, but your WCF RIA traffic is not.

To enable this we will need to add the mime-type of our WCF RIA traffic to the list of mime-types that need to be compressed. On my system the mime-type for my WCF RIA traffic is application/msbin1. I assume this is the same for everybody.

How-to enable GZIP compression for WCF RIA Services traffic:
Open a command box (cmd.exe)
Navigate to C:\Windows\system32\Inetsrv\ and execute the following command to add the application/msbin1 mime-type to the list of types that needs to be compressed:

appcmd.exe set config -section:system.webServer/httpCompression /+”dynamicTypes.[mimeType=’application/msbin1′,enabled=’True’]” /commit:apphost

This will add an entry into the Windows\System32\Inetsrv\Config\applicationHost.config file.

Now restart your IIS server and compression is enabled for the WCF RIA Services.

Before:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 583
Content-Type: application/msbin1
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 11 Aug 2011 17:47:10 GMT

After:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/msbin1
Content-Encoding: gzip
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Thu, 11 Aug 2011 17:48:01 GMT
Content-Length: 336

I hope this post was helpful!

Useful link: http://www.iis.net/ConfigReference/system.webServer/httpCompression