技术文章 > IIS6 Compression

IIS6 Compression

2018-11-17 14:43

文档管理软件,文档管理系统,知识管理系统,档案管理系统的技术资料:

Written by Brad Wilson
Published on June 25, 2003
Reader Rating:
Summary
Windows Server 2003 is, without a doubt, the best platform for running ASP.NET available. Turning on the compression built into IIS6 allows you to save valuable bandwidth with your ASP.NET-based web sites.
很显然,设置IIS6内置的压缩功能可以节省带宽。
Compressible Content
If you follow these directions from Microsoft, you“ll have compression enabled, but still non-functional for ASP.NET. The reason is that the ASP.NET file extension (.aspx) is not set as a valid compressible file extension.
实际上,在IIS6中并不能直接进行设置,可以看到的结果是,ASP.NET 的后缀文件.aspx 并没有设置为可压缩的文件。
To make this change, you“re going to need to edit the Metabase. Edit \Windows\System32\inetsrv\MetaBase.xml with your favorite text editor. Search for “IIsCompressionScheme“. There will be two XML elements, one for deflate and one for gzip. Both elements have properties called HcFileExtensions and HcScriptFileExtensions. These contain a space-delimited list of file extension for compressible content. At a bare minimum, you“ll need to add aspx to the HcScriptFileExtensions list. Note that if the properties are left blank, then all content, regardless of file extension, will be compressed.
为了实现压缩功能,您应该编辑Metabase文件。请用您喜欢的编辑器编辑\windows\system32\inetsrv\metabase.xml文件。
先试图找到IIsCompressionScheme,将有两个元素,deflate,gzip。分别都有属性HcFileExtensions和HcScriptFileExtensions,包含有可以压缩的文件后缀列表。一般来说,您必须添加aspx到HcScriptFileExtensions列表中。如果列表是空的,则必须增加所有相关文件的后缀。
Now fire up a tool like YATT and watch the HTTP stream as you make a request. You should see in the response headers that indicate that the content is being compressed (and it should look like garbage, rather than HTML, since it“s compressed).
您可以用YATT这样的工具进行测试。
What if it Still Doesn“t Work?
I“ve had a rather unique problem that others can“t seem to replicate. I“m going to document it here, in case anybody else runs into a problem where it seems like compression should be working, but isn“t. Don“t do this unless you find compression isn“t working even after following the steps above.
如果仍然不能进行,怎么办?
Open the IIS admin tool, drill into your server, and right-click on “Web Service Extensions“. Choose “Add a new web service extension“. For the extension name, use whatever you want to identify it in the list (I used “HTTP Compression“). You need to add a single required file, which is \Windows\System32\inetsrv\gzip.dll, the ISAPI responsible for doing gzip and deflate compression. Check the “Set extension status to allowed“, then click OK. You should have a new web service extension in your list called “HTTP Compression“ (or whatever you named it), and it should have a status of “Allowed“.
您需要进入IIS的管理工具,点击网站,右键进入Web Service Extensions,选择Add a new web service extension,输入一个名字,然后增加文件\Windows\System32\inetsrv\gzip.dll到列表中。确认Set extension status to allowed是允许的。
About the Author
Brad Wilson is a .NET technology consultant and a frequent contributor to .NET related mailing lists. When not writing at his web log, he spends much of his time looking for inventive ways to break ASP.NET and bend it to his will. :)
Brad lives in beautiful Parker, Colorado. He is an avid game player, including poker, backgammon, cribbage, and Go.
If you have any questions or concerns about his articles, you may contact Brad here.


This article copyright ? 2004 Brad Wilson, unless otherwise noted. All rights reserved. Reproduction prohibited without prior consent.
We are looking for article contributors and reviewers; if you are interested, please read the guidelines.