在 IIS 6 中预压缩静态文件

发布于 2024-11-05 08:03:36 字数 258 浏览 1 评论 0原文

我正在我的网站上对 CSS 和 JS 文件实施 Gzip 压缩,只需要仔细检查一些内容。

文件是否根据每个请求进行压缩?或者是从临时文件夹收集并发送的(如果文件存在)?我只是想确保我的文件不会根据每个请求进行压缩。

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

最后,在路径中使用哈希标签(以通知浏览器文件已更改)和静态文件压缩时,我是否需要担心或配置某些内容?或者它应该可以正常工作。

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

非常感谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨巷深深 2024-11-12 08:03:36

为了充分利用 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>

完成后,使用 YSlow 等 FF 插件测试站点中的页面或 Firebug,使用 Firebug,您可以检查“网络”选项卡中的每个元素,并检查是否将正确的压缩应用于右侧文件类型。

这里有一篇很棒的文章和示例 http ://www.codinghorror.com/blog/2004/08/http-compression-and-iis-6-0.html

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

梦纸 2024-11-12 08:03:36

IIS 6 支持动态和静态压缩。

查看 相关文档不错的博客条目 关于这个主题。

IIS 6 supports both dynamic and static compression.

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

冷清清 2024-11-12 08:03:36

“然后,新压缩的文件将存储在压缩目录中,并且直接从压缩目录提供对该文件的后续请求。换句话说,文件的未压缩版本将返回给客户端,除非文件的压缩版本已经存在存在于压缩目录中。"*

"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."*

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文