asp.Net gzip圧縮の追加

2420 ワード

1:CompressionModuleモジュールのダウンロード

ダウンロードアドレス


2:DC.Web.HttpCompress.dll Webサイトプロジェクトのbinディレクトリに配置
3:webを追加する.config構成
<configSections>
    <sectionGroup name="DCWeb">
      <section name="HttpCompress" type="DC.Web.HttpCompress.Configuration, 
          DC.Web.HttpCompress"/>
    </sectionGroup>
  </configSections>

  <DCWeb>
    <HttpCompress  compressionType="GZip">
<!--      cachefiles  ,   cache  ,                false(   cache)-->
      <CacheSettings cacheFiles="true" path="cache"/>
<!--  jspath csspath,                  -->
      <PathSettings jsPath="javascript" cssPath="css" />
<!--            ,       html,   aspx   *.axd      ,     (   ,CSS )     ! :     gif,   <add mime="image/gif"/>,  jpg   <add mime="image/jpeg"/>-->
      <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>

再検査でOK