使用blowery.Web.HttpCompress.dll对aspx压缩

HttpCompressionModule (HTTP compression for ASP.NET)

An IHttpModule for ASP.NET that provides compression of HTTP Responses。

开源项目:http://code.google.com/p/httpcompress/

本地下载:httpCompress

 

使用指南

  1. Download and install the HttpModule from http://www.blowery.org/. Simply follow this link and download the binary package.

    If for some reason you can't download it from Blowery.org try here
  2. Extract the package and copy the extracted files into the bin folder of your .Net application.
    blowery.Web.HttpCompress.dll
    blowery.Web.HttpCompress.dll.xml
    ICSharpCode.SharpZipLib.dll
    ICSharpCode.SharpZipLib.dll.xml
  3. Modify your Web.config
    1. Add to the configSections
      <sectionGroup name="blowery.web">
       <section name="httpCompress" type="blowery.Web.HttpCompress.SectionHandler, blowery.Web.HttpCompress"/>
      </sectionGroup>
    2. Add to the httpModules section inside system.web (if httpModules section does not exist, create it)
      <httpModules>
      <add name="CompressionModule" type="blowery.Web.HttpCompress.HttpModule, blowery.web.HttpCompress"/>
      </httpModules>
    3. Add to the configuration section
      <blowery.web>
      <httpCompress preferredAlgorithm="deflate" compressionLevel="high">
          <excludedMimeTypes>
          <add type="image/jpeg"/>
          <add type="image/gif"/>
          </excludedMimeTypes>
          <excludedPaths></excludedPaths>
      </httpCompress>
      </blowery.web>
  4. That's it!

For more information or troubleshooting please refer to http://www.blowery.org/

转自:http://capitalhead.com/articles/enable-http-compression-for-your-aspnet-applications.aspx

参考:http://www.dnnskin.com/KnowledgeBase/DotNetNukeDNNSkins/tabid/500/articleType/ArticleView/articleId/23/categoryId/15/How-to-do-a-Blowery-Compression-DotNetNuke-and-Http-Compression.aspx

http://www.codeproject.com/KB/aspnet/httpcompression.aspx

 

中文参考:http://space.itpub.net/7383074/viewspace-469865

 

HTTP Compression with HttpCompress
 

This article describes how to enable HTTP compression for ASP.net web applications without having direct access to the server and by using an HttpModule.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 sitehttp://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.

 转自:http://www.c-sharpcorner.com/UploadFile/Ihelpable/httpcompression05022006094806AM/httpcompression.aspx?ArticleID=b0c4a586-97b4-4fbd-a95a-8b1200f0e068

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值