views:

514

answers:

2

Hello! 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 http://stackoverflow.com/questions/2405595/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

A: 

Hello, 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
Slava
A: 

Hi,

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>
Frank
Thanks, I try this solution tomorrow.