如何在IIS7中获取gzip压缩? [英] How can I get gzip compression in IIS7 working?

查看:219
本文介绍了如何在IIS7中获取gzip压缩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已为IIS7安装静态和动态压缩,以及在我的应用程序设置两个 web.config 虚拟文件夹级别。根据我的理解,我不需要在服务器或站点级别启用压缩,我可以使用我的web.config文件在每个文件夹管理它。



我在我的 .config 文件中有两个设置,用于为我的应用程序自定义gzip:

 < httpCompression dynamicCompressionDisableCpuUsage =90
dynamicCompressionEnableCpUUsage =0>
< scheme name =gzipdll =%Windir%\system32\inetsrv\gzip.dll/>
< dynamicTypes>
< remove mimeType =* / */>
< add mimeType =* / *enabled =true/>
< / dynamicTypes>
< / httpCompression>
< urlCompression doDynamicCompression =true
dynamicCompressionBeforeCache =true/>但是,当我运行应用程序时,我可以清楚地看到gzip不使用,因为我的页面尺寸相同。我也使用 YSlow for FireFox,这也确认我的网页没有gziped。



我在这里缺少什么?在IIS6中,这是一个简单的问题指定文件类型,并设置在0-10之间的压缩级别。我没有看到需要记录指定文件类型或压缩级别,因为默认似乎覆盖文件类型,我没有看到级别在任何地方。

解决方案

在iis 7 beta版本中,forums.iis.net上有一个线程。



微软对他的主要建议是启用失败的请求跟踪找出什么是错误。这可能是IIS7最不被欣赏的功能之一,但肯定是最强大的功能之一。




  • 开启IIS管理员。

  • 前往您的网站,在操作窗格

  • 点击启用。

  • 然后,在功能视图中,点击失败的请求跟踪规则。点击添加,接下来,为状态代码输入200,然后点击完成。



如果没有看到请求跟踪失败在操作窗格中,您需要使用添加角色服务向导(运行状况和诊断\\ \\跟踪)或通过Web平台安装程序(Products \Server \IIS:跟踪),然后关闭并重新打开IIS管理器。



接下来,重新运行测试。这将产生一些日志信息供我们检查。



查看c:\inetpub\logs\FailedReqLogFiles\w3svcx。你会看到一堆名为fr000xx.xml的文件。在浏览器中打开其中的任何一个。 (顺便说一下,如果你在任何地方复制这些文件,确保freb.xsl是有的。此外,不要删除freb.xsl - 如果你这样做,只是删除整个目录或复制它从另一个位置,因为IIS只创建)



点击请求详情标签并选择完成请求跟踪。搜索'compress'的页面 - 你应该在几个方面找到它;一次用于静态内容,一次用于动态内容。



如果没有找到它们,IIS未正确配置。如果你找到它们,你应该看到它们后面是一个compression_success和一个compression_do。成功是自我解释; 'do'表示它做了什么 - 在我的情况下,它显示OriginalSize 1462784 CompressedSize 179482



由于你的工作不工作,希望你会看到不同的东西



确保您在完成后通过在网站的操作窗格中停用失败的请求跟踪功能来关闭此功能。


I have installed Static and dynamic compression for IIS7, as well as setting the two web.config values at my application Virtual Folder level. As I understand it, I don't need to enable compression at the server, or site level anymore, and I can manage it on a per folder basis using my web.config file.

I have two settings in my .config file that I have set to customize gzip for my app:

<httpCompression dynamicCompressionDisableCpuUsage="90"
    dynamicCompressionEnableCpuUsage="0">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
  <dynamicTypes>
    <remove mimeType="*/*"/>
    <add mimeType="*/*" enabled="true" />
  </dynamicTypes>
</httpCompression>
<urlCompression doDynamicCompression="true"
    dynamicCompressionBeforeCache="true" />

However, when I run the application, I can clearly see that gzip is not used, because my page sizes are the same. I am also using YSlow for FireFox, which also confirms that my pages are not being gziped.

What am I missing here? In IIS6 it was a simple matter of specifying the file types, and setting the compression level between 0-10. I don't see the need documented to specify the file types or compression level, since the defaults seem to cover the file types, and I'm not seeing the level anywhere.

解决方案

There was a thread on forums.iis.net about this during the iis 7 beta. Turned out the guy didn't have the modules installed, but it sounds like you've ruled that out from your opening sentence.

Microsofts key advice for him was to enable failed request tracing to find out what was going wrong. This is possibly one of the most under-appreciated features of IIS7, but certainly one of the most powerful.

  • Open IIS Manager.
  • Go to your site, and on the actions pane (the very far right), click 'Failed Request Tracing...' under the 'Configure' section.
  • Click 'enable'.
  • Then, in the features view, click 'Failed request tracing rules'. Click add, next, enter 200 for the status code, next, click finish.

If you don't see "Failed Request Tracing" in the actions pane, you'll need to add the feature to the server - either using the "Add Role Services" wizard (Health and Diagnostics\Tracing) or through the Web Platform Installer (Products\Server\IIS: Tracing), and then close and re-open IIS Manager.

Next, rerun your test. This will generate some log info for us to examine.

Look in c:\inetpub\logs\FailedReqLogFiles\w3svcx. You will see a bunch of files named fr000xx.xml. Open up any one of them in your browser. (By the way, if you copy these files anywhere, make sure freb.xsl is there. Also, don't delete freb.xsl - if you do, just delete the whole directory or copy it from another location, as IIS only creates it once per folder.)

Click the 'request details' tab and select 'complete request trace'. Search the page for 'compress' - you should find it in several areas; once for static content, and once for dynamic content.

If you don't find either of them, IIS isn't configured correctly. If you do find them, you should see them followed by a compression_success and a compression_do. Success is self explanatory; the 'do' indicates what it did - in my case, it showed "OriginalSize 1462784 CompressedSize 179482"

Since yours isn't working, hopefully you will see something different that helps you solve the problem.

Make sure you turn this off when you're done by disabling failed request tracing in the actions pane for your website.

这篇关于如何在IIS7中获取gzip压缩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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