I’ve inherited an ASP.NET (.net 3.5) web app and the corresponding C# client components and a related javascript client.
The server-side components use the default [WebMethod] serialization and, given the size of some of our XML documents (and the verbosity of the element names), I’m curious about options to shrink the size of the documents returned.
I’m open to binary XML, custom serialization of XML (e.g., change ThisVeryLongElementNameWhichShowsUpALot into something shorter), simple compression, moving to JSON, etc. We do have quite a substantial number of individual WebMethods and different objects returned, so the ideal solution would involve changing as little as possible on both sides of the equation.
I understand there will be a CPU/bandwidth tradeoff doing things like compression or custom serialization, so I’d like to benchmark some options without building a giant pile of code.
Could someone please point me at relevant documentation or IIS/VS.NET options to configure to explore these tradeoffs?
I recently tested IIS compression and was happy with the results, after I figured out how to set the compression level. The end result was a 196 kb JSON result compressed to 13.6 kb.
Below are some notes I made for myself on setting up dynamic compression and setting the compression level. I apologize if they are rough as I made them primarily for my own future reference.
In addition, I would definitely advise trying JSON over XML as it provides a much more compact result. I don’t have specific numbers, but off-hand, my recollection is that JSON was around 50% smaller than XMl.
Install dynamic compression if necessary
Windows 7:
Windows Server 2008:
Enable dynamic compression in IIS
Enable for “application/json” and “application/xml”
<dynamicTypes>, add the following elements:Restart IIS.
To verify, check in Fiddler and make sure the ‘Decode’ button is not selected (the Decode button should be on the main toolbar). You should see that the response ‘Content-Encoding’ header shows ‘gzip’, and that the response is compressed:
Advanced Settings
Set the compression level using the following command (the default level is 0):
See these sites for additional details:
Making the most out of IIS compression – Part 1: IIS 7 configuration
IIS 7 Compression. Good? Bad? How much?
My initial testing of a json response: