SIGN UP MEMBER LOGIN:    
ARTICLE

HTTP Compression with HttpCompress

Posted by Praveen K Prasad Articles | Internet & Web May 02, 2006
This article describes how to enable HTTP compression for ASP.net web applications without having direct access to the server and by using an <b>HttpModule.</b>
Reader Level:

Introduction

This article is all about how to integrate HTTP compression to your ASP.net web applications with the help of a free httpmodule named httpcompress. It assumes that you've already downloaded the module binaries from the authors site http://www.blowery.org/code/httpcompressionmodule.html.

Http compression is actually a performance optimization technique as documented in the HTTP1.1 protocol standard. It simply means that the Web Server will compress data, and send a compressed page to the browser, which the browser could decompress and display. This reduces the amount of data to be transferred from server to the client and so will speed up process. The speed increase is most noticable over slow connections.

The HttpCompress module is actually an httpmodule that can be plugged into your web application by editing the application configuration and it involves no recompilation of the entire project.

How to achieve it

The module we're going to use comes as two dll files

  • blowery.Web.HttpCompress.dll 
  • ICSharpCode.SharpZipLib.dll

After obtaining the files, please follow the steps below

  1. Place the files inside the 'bin' folder of your application.

  2. Open the application's configuration file, "web.config" and add the following entries to it.

  3. Locate the tag <configuration> , it is there in the starting you needn't require to search it out. Just below it add the segment.

    <configSections>

    <sectionGroup name="blowery.web">

    <section name="httpCompress" type="blowery.Web.HttpCompress.SectionHandler, blowery.Web.HttpCompress"/>

    </sectionGroup>

    </configSections>

     

    <blowery.web>

    <httpCompress preferredAlgorithm="gzip" compressionLevel="high">

    <excludedMimeTypes>

    <add type="image/jpeg"/>

    <add type="image/png"/>

    <add type="image/gif"/>

    </excludedMimeTypes>

    <excludedPaths>

    <add path="NoCompress.aspx"/>

    </excludedPaths>

    </httpCompress>

    </blowery.web>


    This describes a new configSection named <blowery.web> and later this <blowery.web> section is configured. It contains a subsection <httpCompress> thet have to major attributes named
    , preferredAlgorithm and compressionLevel . preferredAlgorithm specifies which compression algorith is to be used and supported values are gzip/deflate/default. The compressionLevel attribute specifies the amount of comression and the possible values are high/normal/low

    The next section is excludedMimeTypes that specifies which MIME types are to be excluded from compression(You'll not benefit from compressing a jpg/gif image which is already compressed). You may add as many number of MIME types and they will not b compressed by HttpCompress while serving

    Then comes the excludedPaths section that allows you to exclude a specific path from being compressed.The example segment shows a page Nocompress.aspx being excluded.

  4. Plug-in the module into your application by adding the following lines just below the <system.web> section or anywhere inside it.

    <httpModules>

    <add name="CompressionModule" type="blowery.Web.HttpCompress.HttpModule, blowery.web.HttpCompress"/>

    </httpModules>


    This registers the http module with the application instance and it works as a filter for response to the client without directly sending the response to the client, HttpCompress compresses it and sends to the client.

NB:Its not necessary to use compression with your app by using an http module, if the hosted server already performs compression. Client browsers need to support compression for this to work as specified by "Accept-Encoding" in their request.

Login to add your contents and source code to this article
share this article :
post comment
 

Hi! I find the solution I downloaded using the version of "ICSharpCode.SharpZipLib.dll" is "0.6.0.0". But unfortunately my another page is using the same name dll(""ICSharpCode.SharpZipLib.dll"") but using version "0.85.5.452". How could we upgrade it? I don't have the source code of "blowery.Web.HttpCompress.dll ". Many thanks! Best Regards, Kent He HongKong

Posted by kent he Jun 17, 2011

Hi,

Your compression Technique really helped me lot. When i put my Login page in ExcludedPath, the event compression is applying on this page, bcoz this page contains Ajax. So tell me how to exclude this compression on a Particular Page. Please Respond Immediately.

 

Thanks & Regards

Vimal Kumar

India

Posted by vimal kumar May 24, 2007

Hi, your compression really helped me lot, But i put Login page in ExcludedPath ,But event compression is applying on this page ,bcoz this page contains Ajax.

Posted by vimal kumar May 24, 2007

Hello Parveen!

Nice atricle but can you please tell that, Is every browser supports decompression of HHTP Web request?

 

Thank You

Adnan Hasan

Posted by Adnan Hasan May 11, 2006
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Nevron Gauge for SharePoint
Become a Sponsor