title: What is the easiest way to add compression to WCF in Silverlight?
body: <p>I have a silverlight 2 beta 2 application that accesses a WCF web service.  Because of this, it currently can only use basicHttp binding.  The webservice will return fairly large amounts of XML data.  This seems fairly wasteful from a bandwidth usage standpoint as the response, if zipped, would be smaller by a factor of 5 (I actually pasted the response into a txt file and zipped it.).  </p>
  
  <p>The request does have the "Accept-Encoding: gzip, deflate" - Is there any way have the WCF service gzip (or otherwise compress) the response?</p>
  
  <p>I did find this <a href="http://www.vistax64.com/indigo/113763-wcf-client-j2ee-server-using-gzip.html" rel="noreferrer">link</a> but it sure seems a bit complex for functionality that should be handled out-of-the-box IMHO.</p>
  
  <p>OK - at first I marked the solution using the System.IO.Compression as the answer as I could never "seem" to get the IIS7 dynamic compression to work.  Well, as it turns out:</p>
  
  <ol>
  <li><p>Dynamic Compression on IIS7 <strong>was</strong> working al along.  It is just that Nikhil's Web Developer Helper plugin for IE did not show it working.  My guess is that since SL hands the web service call off to the browser, that the browser handles it "under the covers" and Nikhil's tool never sees the compressed response.  I was able to confirm this by using Fiddler which monitors traffic external to the browser application.  In fiddler, the response was, in fact, gzip compressed!!</p></li>
  <li><p>The other problem with the System.IO.Compression solution is that System.IO.Compression does not exist in the Silverlight CLR.</p></li>
  </ol>
  
  <p>So from my perspective, the EASIEST way to enable WCF compression in Silverlight is to enable Dynamic Compression in IIS7 and write no code at all.</p>