Feeds:
Posts
Comments

Posts Tagged ‘optimize’

Keep your Silverlight app running fast by compressing your service responses. Imagine you’re downloading 1MB worth of text. Compressed, that same text can usually be reduced to under 200K. This reduction can be significant enough to be noticable to even clients on good internet connections and over time will save you money on bandwidth usage.

Fortunately, there’s NO need to find a 3rd party zip component or to try to do it yourself. IIS has everything all built right in, you just need to enable it.

The way it works is, the browser sends up an http header of “Accept-Encoding” with gzip and/or deflate as the value with each request to your WCF service. As long as IIS is configured correctly, the server will automatically compress the response from the service and the client will automatically decompress it before your code enters the picture. Not a single line of code is required on our part to take full advantage of this built in compression feature that works across most major browsers.

To set up IIS6 to participate you need to (sorry, haven’t tried this on IIS7):

1) In the IIS console, right click on “Web Sites”, choose properties, select the Services tab and check “Compress application files”

iis

2) Also in the IIS console, go to the Web Service Extensions folder and click the “Add a new Web service extension” link. In the dialog that appears, enter a name for the extension. I named mine “gzip”. Next, enter the path of the dll capable of zipping the responses (c:\windows\system32\inetsrv\gzip.dll), and check “Set extension status to Allowed”.

extension1

3) Run the following command lines to update metabase.xml:

CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions “asp” “dll” “exe” “svc”
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions “asp” “dll” “exe” “svc”
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel 9
CSCRIPT.EXE ADSUTIL.VBS SET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel 9

4) Restart IIS (you can right click on the computer name in the IIS console, choose All Tasks, and select “Restart IIS”). Not 100% sure this is necessary.

5) Wait. It took my server on Amazon EC2 approximately 3 minutes before the changes from step #2 flowed to the metabase.xml file. You can always go check by looking at the date modified of c:\windows\system32\inetsrv\metabase.xml

In the end, you can test that it’s working by going to PipeBoost and typing in the url of your .svc file. Also, when running your app, you can use a tool like fiddler2 to show you the data actually coming down to the client along with an indicator that it is compressed.

That’s it, don’t do a think to your Silverlight app but watch it instantenously start downloading data faster!

Read Full Post »