JSON webservice response compression in IIS 7

I have trouble with JSON response compression. I look to response headers after uploading website to production server (Windows 2008, IIS 7) and found uncompressed response. Turning on "Enabled static compression" and ""Enable dynamic compression" in IIS control panel does not effect. ASPX pages was responsed gzipped, but webservice response uncompressed.

I looked to google, but no answer found about this trouble. Also, I try this json ihttpmodule compression way (and adding to web.config this module) - but this source is excellent working at development machine with ASP.NET development server (and have seven times response size reduced) and totally ignored at IIS7.

How I can apply gzip compression to json responses from my webservice? Thanks.

PS .NET 3.5

Answers


I stumbled across the same problem with JsonCompressionModule. It was working on the development server but not on IIS 7. I figured out that under IIS 7 it isn't enough to add the handle under system.web but also under system.webServer (see below). After this change it works fine on IIS 7.

<system.web>
 <httpModules>
   <add name="JsonCompressionModule" type="JsonCompressionModule"/>
 </httpModules>
</system.web>

<system.webServer>
 <modules>
  <add name="JsonCompressionModule" preCondition="managedHandler" type="JsonCompressionModule"/>
 </modules>
</system.webServer>

IIS dynamic compression uses the response content type header to determine if it should compress the content or not. The default settings do not compress "application/json". You can find more information at http://www.iis.net/configreference/system.webserver/httpcompression

To add it, open an admin command prompt, run the commands below then restart the IIS service.

cd \Windows\System32\inetsrv
appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost

You may want to add a few other content types. The only application/* types the default dynamic settings compress is application/x-javascript.


Please try and examine what are the request headers which the client sends. Accept-Encoding should have gzip or deflate value. Make sure though that the client is able to decompress JSON. There is a solution which is able to set Accept-Encoding and perform GZIP compression all together—Helicon Ape (http://www.helicontech.com/ape/). The following configuration will do both the tricks:

# Manually set required request header
RequestHeader append Accept-Encoding gzip early

# Enable high-level (9) comression for JSON files
SetEnvIf mime application/json gzip=9

Need Your Help

Accessing the value that's not part of the form

html forms form-submit

In my html I have a combo box which list all the available usertypes and then the input varies by what the user selects on the combo box so you can see that I have my onchange.

How to solve this peculiar nested for loops exercise?

c recursion for-loop procedural-programming repetition

I've been studying C programming for a while and I've stumbled on this exercise I can't seem to solve: