about enable gzip encoding in iis7

Discussion in 'Site Programming, Development and Design' started by likeuclinux, Jan 25, 2011.

  1. I have a asp.net mvc application, can I enable ii7 gzip encoding by following article:

    http://blogs.msdn.com/b/vivekkum/archive/2009/02/18/http-compression-in-iis-6-and-iis-7-using-service-account.aspx

    or I have to use this work around:


    Global Gzip in HttpModule

    If you don't have access to the final IIS instance (shared hosting...) you can create a HttpModule that adds this code to every HttpApplication.Begin_Request event :

    HttpContext context = HttpContext.Current;
    context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
    HttpContext.Current.Response.AppendHeader("Content-encoding", "gzip");
    HttpContext.Current.Response.Cache.VaryByHeaders["Accept-encoding"] = true;
     
  2. Ray

    Ray

    Unfortunately GZip is simply not supported on our shared hosting environment. Bear in mind compressing a file and uploading it to the server then uncompressing it remotely bypasses a lot of the security on the server.
     
  3. I am talking about the page content encoding of html, javascript and css file

    in that case, I am not uploading compressed file to server, right?:confused:
     
  4. Ray

    Ray

    Yes. That is correct.
     
  5. How to enable GZIP output compression from Web.config only

    I got my ASP.NET MVC 3 website compressing output via GZIP by just adding the following XML to my Web.config file.

    Code:
      <system.webServer>
        <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="*/*" enabled="false"/>
          </dynamicTypes>
          <staticTypes>
            <add mimeType="text/*" enabled="true"/>
            <add mimeType="message/*" enabled="true"/>
            <add mimeType="application/javascript" enabled="true"/>
            <add mimeType="*/*" enabled="false"/>
          </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
      </system.webServer>
    
    Both Google Page Speed and Yahoo YSlow recommend using GZIP to compress output from your app. It might just be my wishful thinking, but my page seems faster to load with this enabled.

    Some links:

     
  6. How to enable GZIP output compression from Web.config only

    I got my ASP.NET MVC 3 website compressing output via GZIP by just adding the following XML to my Web.config file.

    Code:
      <system.webServer>
        <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="*/*" enabled="false"/>
          </dynamicTypes>
          <staticTypes>
            <add mimeType="text/*" enabled="true"/>
            <add mimeType="message/*" enabled="true"/>
            <add mimeType="application/javascript" enabled="true"/>
            <add mimeType="*/*" enabled="false"/>
          </staticTypes>
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
      </system.webServer>
    
    Both Google Page Speed and Yahoo YSlow recommend using GZIP to compress output from your app. It might just be my wishful thinking, but my page seems faster to load with this enabled.

    Some links:

     
  7. Ray

    Ray

    Installing GZIP on a shared hosting servers, I'm not sure if that is such as good idea.
     
  8. If that application is running on our servers enabling gzip in your web.config won't have any effect since the server will not execute gzip.

    Whether or not it's effective for most applications is debatable, and since the gain is marginal at best, it isn't worth the server resources to use it. In fact, on a shared erver, if gzip was in wide use the net effect on overall performance would be negative. On a dedicated server or a VPS it might make sense for a large application. But on a shared server, as Ray mentioned, not such a good idea.
     

Share This Page