设置过程如下:
1、打开Internet信息管理器,右击”网站“(一定要注意是【网站】文件夹,不是那个【默认网站】),点”属性“菜单-选”服务“选项卡,选上“压缩应用程序文件”复选框,那个“压缩静态文件”好像可以不选
2、打开Web服务扩展,在其中增加Gzip压缩扩展并启用
3、设置IIS可进行压缩的文件类型,这一步骤比较繁杂,有一高人写了一个批处理文件,用来简化此操作,批处理内容如下:
IISreset.exe /stop
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "ppt" "xls" "xml" "pdf" "xslt" "doc" "xsl" "htc" "js" "css"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx" "ashx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "aspx" "asmx"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
cscript.exe adsutil.vbs set W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"
IISreset.exe /restart
把该批处理文件拷贝到c:\inetpub\AdminScripts下执行即可
如果你设置完成了,可以访问下面的地址测试效果:
http://www.port80software.com/tools/compresscheck.asp
这个工具的使用建立在你的网站在Internet上可访问的基础上。如果哪位高人有可以本地使用的工具,告诉我一下,不胜感激!
参考文档:
http://angryhacker.com/blog/archive/2007/09/08/iis-compression-and-.net-web-services.aspx
http://www1.lob.cn/n2087c8.shtml
http://www.cnblogs.com/Elong/archive/2006/12/14/592394.html