Wednesday, March 30, 2011

Enabling dynamic compression (gzip, deflate) for WCF Data Feeds, OData and other custom services in IIS7

I'm working on a thing that uses an HttpWebRequest to talk to a backend WCF Data Service and it'd be ideal if the traffic was using HTTP Compression (gzip, deflate, etc).

On the client side, it's easy to just add code like this
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
or more manually

var request = HttpWebRequest.Create("http://foofoo");
request.Headers["Accept"] = "application/json";
request.Headers["Accept-Encoding"] = "gzip, deflate";
However, you need to make sure this is installed and turned on in IIS7 in you server.
Launch your IIS Manager and go to the Compression module.

image_5.png

Read more: Scott Hanselman