在IIS 6中预压缩静态文件 [英] Pre-compress static files in IIS 6

查看:230
本文介绍了在IIS 6中预压缩静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上为CSS和JS文件实现Gzip压缩,只需要仔细检查一下。



每次请求都压缩文件?或者是从临时文件夹收集和发送(如果文件存在)?



此外,这是默认行为还是需要一些额外的配置?



最后,当在路径中使用哈希标记(以通知浏览器文件已更改)和静态文件压缩时,我需要担心或配置某些东西吗?



编辑:我只是使用静态压缩



p>

解决方案

为了充分利用IIS压缩,您需要在元数据库文件中添加一些额外的位。


  1. 备份您的元基档案。

  2. 启用实时编辑IIS中的元基本文件(或者您需要在完成后重新启动IIS。)

找到IIsCompressionScheme并对元基本文件进行以下编辑

 < 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>完成后,使用FF插件(例如YSlow或 http://getfirebug.com/rel =nofollow> Firebug ,使用Firebug,您可以检查Net选项卡中的每个元素,并检查是否正确的压缩应用于正确的文件类型。



这里有一个很好的文章,例如 http://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html


I am implementing Gzip compression for CSS and JS files on my site and just need to double check something.

Is the file compressed on every request? or is it collected and sent from the Temporary folder (if the file exists)? I just want to be sure that my files are not compressed on every request.

Also, is this a default behaviour or do I need some extra configurtion?

And last, do I need to worry or configure something when using hash tags in the path (to inform the browser that the file has changed) and static file compression? or it should work with no problem.

Edit: I am just using static compression

Many thanks

解决方案

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中预压缩静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆