Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iis7 compress dynamic content from custom handler

I am having trouble getting dynamic content coming from a custom handler to be compressed by IIS 7.

Our handler spits out json data (Content-Type: application/json; charset=utf-8) and responds to url that looks like: domain.com/example.mal/OperationName?Param1=Val1&Param2=Val2

In IIS 6, all we had to do was put the edit the MetaBase.xml and in the IIsCompressionScheme element make sure that the HcScriptFileExtensions attribute had the custom extension 'mal' included in it.

Static and Dynamic compression is turned out at the server and website level. I can confirm that normal .aspx pages are compressed correctly. The only content I cannot have compressed is the content coming from the custom handler.

I have tried the following configs with no success:

<handlers>
  <add name="MyJsonService" verb="GET,POST" path="*.mal" type="Library.Web.HttpHandlers.MyJsonServiceHandlerFactory, Library.Web" />
</handlers>

<httpCompression>
  <dynamicTypes>
    <add mimeType="application/json" enabled="true" />
  </dynamicTypes>
</httpCompression>

_

<httpCompression>
  <dynamicTypes>
    <add mimeType="application/*" enabled="true" />
  </dynamicTypes>
</httpCompression>

_

<staticContent>
  <mimeMap fileExtension=".mal" mimeType="application/json" />
</staticContent>
<httpCompression>
  <dynamicTypes>
    <add mimeType="application/*" enabled="true" />
  </dynamicTypes>
</httpCompression>

Thanks in advance for the help.

like image 856
Malloc Avatar asked Mar 25 '10 21:03

Malloc


People also ask

How to set dynamic compression?

Open Programs and Features: Control Panel > Programs and Features. Select Turn Windows features on or off. Navigate to Internet Information Services > World Wide Web Services > Performance Features > Dynamic Content Compression.

How do I enable dynamic content compression?

In Control Panel, click Programs and Features, and then click Turn Windows features on or off. Expand Internet Information Services, expand World Wide Web Services, expand Performance Features, and then select Dynamic Content Compression and/or Static Content Compression. Click OK. Click Close.

How do I install dynamic content compression in IIS 7?

In the Web Server (IIS) panel, scroll down to the “Role Services” section, and then click “Add Role Services” On the “Select Role Services” page of the “Add Role Services Wizard”, select “Dynamic Content Compression” and then click “Next”


1 Answers

looks like it is a bug in the IIS compression. I needed to add the following line to the applicationHost.config file (under httpCompression ) instead of the web.config

        <dynamicTypes>
            <add mimeType="application/json; charset=utf-8" enabled="true" />
        </dynamicTypes>

found some extra help from here: http://forums.iis.net/p/1162828/1925766.aspx

like image 111
Malloc Avatar answered Sep 28 '22 18:09

Malloc