问题描述
我已经为 IIS7 安装了静态和动态压缩,并在我的应用程序 Virtual Folder
级别设置了两个 web.config
值.据我了解,我不再需要在服务器或站点级别启用压缩,我可以使用我的 web.config 文件在每个文件夹的基础上进行管理.
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.
我的 .config
文件中有两个设置,用于为我的应用自定义 gzip:
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%system32inetsrvgzip.dll" />
<dynamicTypes>
<remove mimeType="*/*"/>
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
</httpCompression>
<urlCompression doDynamicCompression="true"
dynamicCompressionBeforeCache="true" />
但是,当我运行应用程序时,我可以清楚地看到没有使用 gzip,因为我的页面大小是相同的.我还在为 FireFox 使用 YSlow,这也证实了我的页面没有被压缩.
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.
我在这里缺少什么?在 IIS6 中,指定文件类型并将压缩级别设置在 0-10 之间很简单.我没有看到需要指定文件类型或压缩级别,因为默认值似乎涵盖了文件类型,而且我在任何地方都没有看到级别.
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.
推荐答案
在 iis 7 beta 期间,forums.iis.net 上有一个关于此的主题.原来这家伙没有安装模块,但听起来你已经从你的开场白中排除了这一点.
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.
Microsoft 对他的主要建议是启用失败的请求跟踪以找出问题所在.这可能是 IIS7 中最被低估的功能之一,但肯定是最强大的功能之一.
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.
- 打开 IIS 管理器.
- 转到您的站点,然后在操作窗格(最右侧)上,点击配置"部分下的失败的请求跟踪...".
- 点击启用".
- 然后,在功能视图中,点击失败的请求跟踪规则".点击添加,下一步,状态码输入200,下一步,点击完成.
如果您在操作窗格中没有看到失败的请求跟踪",则需要将该功能添加到服务器 - 使用添加角色服务"向导(运行状况和诊断跟踪)或通过Web 平台安装程序(ProductsServerIIS: Tracing),然后关闭并重新打开 IIS 管理器.
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 DiagnosticsTracing) or through the Web Platform Installer (ProductsServerIIS: Tracing), and then close and re-open IIS Manager.
接下来,重新运行您的测试.这将生成一些日志信息供我们检查.
Next, rerun your test. This will generate some log info for us to examine.
查看 c:inetpublogsFailedReqLogFilesw3svcx.您将看到一堆名为 fr000xx.xml 的文件.在浏览器中打开其中任何一个.(顺便说一句,如果您将这些文件复制到任何地方,请确保 freb.xsl 在那里.另外,不要删除 freb.xsl - 如果这样做,只需删除整个目录或从另一个位置复制它,因为 IIS 只会创建每个文件夹一次.)
Look in c:inetpublogsFailedReqLogFilesw3svcx. 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.
如果您没有找到其中任何一个,则说明 IIS 配置不正确.如果您确实找到了它们,您应该会看到它们后跟一个compression_success 和一个compression_do.成功是不言自明的;do"表示它做了什么——在我的例子中,它显示OriginalSize 1462784 CompressedSize 179482"
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 压缩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!