locked
gzip compression not working even though allowed in applicationHost.config RRS feed

  • Question

  • User-1246604461 posted

    I want to enable gzip compression for my site running on ASP.NET4.5 with IIS7.5, but can't get it to compress.

    I'm on shared hosting, so I can't set this in IIS directly.

    **applicationHost.config**

    I changed this from `Deny` to `Allow` (I read here that I should not change the `allowDefinition` setting: http://stackoverflow.com/questions/721505/how-do-you-change-the-allowdefinition-section-attribute-using-appcmd-in-iis-7/2894695)

    <section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Allow" />

    **my website's web.config**

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="application/x-javascript" enabled="true"/>
    <add mimeType="application/javascript; charset=utf-8" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
    <add mimeType="text/*" enabled="true"/>
    <add mimeType="message/*" enabled="true"/>
    <add mimeType="application/javascript" enabled="true"/>
    <add mimeType="application/x-javascript" enabled="true"/>
    <add mimeType="application/javascript; charset=utf-8" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
    </staticTypes>
    </httpCompression>



    When I check with Fiddler I see no gzip compression.

    Thursday, January 16, 2014 5:32 AM

All replies

  • User-837620913 posted

    If you are using IIS 7.5, then use the new UrlCompression element, like this:

    <configuration>
       <system.webServer>
          <urlCompression doStaticCompression="true" doDynamicCompression="false" />
       </system.webServer>
    </configuration>

    See more here: http://www.iis.net/configreference/system.webserver/urlcompression

    You can enable Gzip compression, however if your host has not allowed you to set these settings then they won't work.

    Thursday, January 16, 2014 5:44 AM
  • User-1246604461 posted

    I'm using IIS7.5.7600.16385 on Windows 7 locally and IIS7.5.7600.16385 on Windows Server 2008 R2 on my production server.

    I added your code to my web.config but still no compression occurs. :(
    To simulate my production environment I unchecked static and dynamic compression (just like on my shared server) on my local IIS in the compression module.

    Also what is the difference between your solution and gzip? Better/worse/same performance? Other pros and cons?

    What else can this be?

    Thanks!

    Thursday, January 16, 2014 6:03 AM
  • User-1378019758 posted

    Hi Peter,

    You need to ask your provider to enable Gzip compression on IIS. If they dont allow it, your gzip compression wont work. 

    Thursday, January 16, 2014 9:59 PM
  • User-1454326058 posted

    Hi Peter,

    Have the dynamic compression and Static Content Compression installed in your shared hosting server. Please check it.

    Windows Server 2008 or Windows Server 2008 R2

    1. On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
    2. In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
    3. In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
    4. On the Select Role Services page of the Add Role Services Wizard, select Dynamic Content Compression if you want to install dynamic compression and Static Content Compression if you want to install static compression, and then click Next.
    5. On the Confirm Installation Selections page, click Install.
    6. On the Results page, click Close.

     Windows Vista or Windows 7

    1. On the taskbar, click Start, and then click Control Panel.
    2. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
    3. Expand Internet Information Services, then World Wide Web Services, then Performance Features.
    4. Select Http Compression Dynamic if you want to install dynamic compression and Static Content Compression if you
    5. Click OK.

    On the other hand, please refer to this link to check the steps to configuring HTTP Compression in the IIS:

    # Configuring HTTP Compression in IIS 7

    http://technet.microsoft.com/en-us/library/cc771003(v=ws.10).aspx

    Thanks

    Best Regards  

    Friday, January 17, 2014 1:11 AM
  • User-1246604461 posted

    Ok, I think it gets weirder:

    I see in the Windows 2008 server manager that Statis content compression is installed, but Dynamic is not.

    Then when I go to IIS to my site and the module compression I see now that Enabled Dynamic compression is enabled (even though aparently not installed) but greyed out, and static content compression is checked. So I must have overlooked it being already active on my production server.

    Nonetheless: even though both static and dynamic content compression are enabled, I see no compression occuring using Fiddler.

    Why?

    Friday, January 17, 2014 3:27 AM
  • User-1454326058 posted

    Hi Peter,

    I see now that Enabled Dynamic compression is enabled (even though aparently not installed) but greyed out

    Since it is greyed out, I think it just displayed.

    Nonetheless: even though both static and dynamic content compression are enabled, I see no compression occuring using Fiddler.

    Do you mean, you get the same result even though have been installed the Dynamic Compression.

    Thanks

    Best Regards  

    Friday, January 17, 2014 4:15 AM
  • User-1246604461 posted

    Starain chen - MSFT

    Since it is greyed out, I think it just displayed.

    It is greyed out but it IS checked...so what do you mean by "just displayed"?

    Friday, January 17, 2014 6:21 AM
  • User-1454326058 posted

    Hi Peter,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Thanks

    Best Regards  

    Tuesday, January 21, 2014 3:40 AM
  • User-918306365 posted

    @Peter

    I have read through your post and I see that you have mentioned that dynamic compression is grayed out. This option will be grayed out if dynamic compression module is not installed. So we need to follow the below steps.

    1) Remove the server from shared configuration.

    2) Install dynamic compression module from server in IIS roles and services.

    3) Now the dynamic compression option should be enabled.

    4) Export the current configuration into the share and now you can enable shared configuration.

    Give it a try and please let me know how it goes or if you have any questions.

    Thank you.
    ----------------------------------------------------------------
    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

     

    Wednesday, January 22, 2014 8:07 AM