ASP.NET页面进行GZIP压缩优化的几款压缩模块的使用简介及应用测

2019-05-12 09:02:50王振洲

      <IncludedMimeTypes> 
        <add mime="text/html" /> 
      </IncludedMimeTypes> 
      <!--配置不压缩何种类型资源请使用: 
      <ExcludedMimeTypes> 
        <add mime="text/html" /> 
      </ExcludedMimeTypes> 
       注意:ExcludedMimeTypes及IncludedMimeTypes只需要配置一个就可以,如果像上面那样配置ExcludeMimeTypes的话,则表明除html类型的资源外,其它资源都会被压缩--> 
        <ExcludedPaths> 
<!--设定不启用压缩的页面路径,下面设定了nocompress目录下的default.aspx页面将不会启用压缩功能,但其它页面则正常启用压缩--> 
          <add path="~/NoCompress/Default.aspx" /> 
        </ExcludedPaths> 
      </HttpCompress> 
  </DCWeb> 

  <!-- The js.axd and css.axd must be enabled to allow javascript and css  
      compression --> 
  <httpHandlers> 
<!--如果不需要使用到此功能的话可删掉此配置节--> 
    <add verb="*" path="js.axd,css.axd"  
        type="DC.Web.HttpCompress.CompressionHandler,DC.Web.HttpCompress"/> 
  </httpHandlers> 
  <!-- The compression module must be enabled for the WebResource.axd to be  
       compressed --> 
  <httpModules> 
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule,  
        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,  
        PublicKeyToken=31bf3856ad364e35"/> 
<!--设定启用压缩模块的参数--> 
    <add name="HttpCompressModule"  
        type="DC.Web.HttpCompress.HttpModule,DC.Web.HttpCompress"/> 
  </httpModules> 

配置好后,压缩模块就可以正常工作了!

小提示:如果web.config配置了