Pre-compress static files in IIS 6

别来无恙 提交于 2019-12-04 17:17:16

In order to get the most out of IIS compression you will need to add a few extra bits into the metabase file.

  1. Backup your meta base file.
  2. Enable live edit to the meta base file in IIS (or you need to restart IIS when your done.)

find the IIsCompressionScheme and make the following edits to the meta base file

<IIsCompressionScheme   Location ="/LM/W3SVC/Filters/Compression/deflate"
        HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
        HcCreateFlags="0"
        HcDoDynamicCompression="TRUE"
        HcDoOnDemandCompression="TRUE"
        HcDoStaticCompression="TRUE"
        HcDynamicCompressionLevel="10"
        HcFileExtensions="htm
            html
            css
            js
            txt
            xml"
        HcOnDemandCompLevel="10"
        HcPriority="1"
        HcScriptFileExtensions="asp
            dll
            aspx
            axd
            ashx
            asbx
            asmx
            swf
            asmx
            exe"
    >
</IIsCompressionScheme>
<IIsCompressionScheme   Location ="/LM/W3SVC/Filters/Compression/gzip"
        HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
        HcCreateFlags="1"
        HcDoDynamicCompression="TRUE"
        HcDoOnDemandCompression="TRUE"
        HcDoStaticCompression="TRUE"
        HcDynamicCompressionLevel="10"
        HcFileExtensions="htm
            html
            js
            css
            txt
            xml"
        HcOnDemandCompLevel="10"
        HcPriority="1"
        HcScriptFileExtensions="asp
            dll
            aspx
            axd
            ashx
            asbx
            asmx
            swf
            asmx
            exe"
    >
</IIsCompressionScheme>

Once done test a page from your site using a FF plug in like YSlow or Firebug, with Firebug you can inspect each element in the Net tab and check if the right compression is being applied to the right file types.

There is a great article with examples here http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html

IIS 6 supports both dynamic and static compression.

Have look at the relevant documentation and a decent blog entry on the subject.

"The newly compressed file is then stored in the compression directory, and subsequent requests for that file are serviced directly from the compression directory. In other words, an uncompressed version of the file is returned to the client unless a compressed version of the file already exists in the compression directory."*

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!