不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
IIS6.0配置使用GZip压缩页面文件
编辑:dnawo 日期:2009-12-29
使用GZip压缩页面文件,既可以降低站点流量,减轻服务器负担,又可以提高用户打开页面的速度,是非常有优势的。要启用GZip压缩,既可以在页面程序中设置(见《ASP.NET页面启用gzip压缩》),也可以在IIS服务器中设置,今天我们看看怎么在IIS6.0中配置使用GZip压缩。
3步开启IIS6.0GZip压缩功能
①在IIS中打开网站属性,切换到"服务"选项卡,钩选"压缩应用程序文件"和"压缩静态文件":


②右键点击"Web 服务扩展",选择"添加一个新的 Web 服务扩展",设置如下:


③在命令行下执行"iisreset /restart",重启IIS服务,这样就可以了;
配置启用GZip压缩的文件类型
①在命令行下执行"iisreset /stop",停止IIS服务(开启状态下MetaBase.xml只读);
②打开C:\WINDOWS\system32\inetsrv\MetaBase.xml,找到:
引用内容
·HcDynamicCompressionLevel和HcOnDemandCompLevel表示压缩率,通常都设置为9;
·在HcFileExtensions添加要启用GZip压缩的静态文件扩展名;
·在HcScriptFileExtensions添加要启用GZip压缩的动态文件扩展名;
·保存修改;
③在命令行下执行"iisreset /start",开启IIS服务;
附加说明
·在IIS服务器配置使用GZip压缩有哪些优势?
相比在页面程序中设置,在服务器上设置开启/关闭GZip压缩非常方便,更重要的一点是,服务器并非总对设置的文件类型进行GZip压缩,当客户端不支持GZip压缩时,服务器就不会对页面文件进行压缩,这若在页面程序中实现,得加些判断才行,都麻烦许多。测试代码:
3步开启IIS6.0GZip压缩功能
①在IIS中打开网站属性,切换到"服务"选项卡,钩选"压缩应用程序文件"和"压缩静态文件":


②右键点击"Web 服务扩展",选择"添加一个新的 Web 服务扩展",设置如下:


③在命令行下执行"iisreset /restart",重启IIS服务,这样就可以了;
配置启用GZip压缩的文件类型
①在命令行下执行"iisreset /stop",停止IIS服务(开启状态下MetaBase.xml只读);
②打开C:\WINDOWS\system32\inetsrv\MetaBase.xml,找到:

<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
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>
HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
HcCreateFlags="1"
HcDoDynamicCompression="TRUE"
HcDoOnDemandCompression="TRUE"
HcDoStaticCompression="TRUE"
HcDynamicCompressionLevel="10"
HcFileExtensions="htm
html
txt"
HcOnDemandCompLevel="10"
HcPriority="1"
HcScriptFileExtensions="asp
dll
exe"
>
</IIsCompressionScheme>
·HcDynamicCompressionLevel和HcOnDemandCompLevel表示压缩率,通常都设置为9;
·在HcFileExtensions添加要启用GZip压缩的静态文件扩展名;
·在HcScriptFileExtensions添加要启用GZip压缩的动态文件扩展名;
·保存修改;
③在命令行下执行"iisreset /start",开启IIS服务;
附加说明
·在IIS服务器配置使用GZip压缩有哪些优势?
相比在页面程序中设置,在服务器上设置开启/关闭GZip压缩非常方便,更重要的一点是,服务器并非总对设置的文件类型进行GZip压缩,当客户端不支持GZip压缩时,服务器就不会对页面文件进行压缩,这若在页面程序中实现,得加些判断才行,都麻烦许多。测试代码:
复制内容到剪贴板
程序代码

WebRequest Request = WebRequest.Create("http://www.qq.com/");
Request.ContentType = "application/x-www-form-urlencoded";
Request.Method = "GET";
//Request.Headers["Accept-Encoding"] = "gzip"; //告知服务器支持gzip解压
WebResponse Response = Request.GetResponse();
using (StreamReader reader = new StreamReader(Response.GetResponseStream(), Encoding.GetEncoding("gb2312")))
{
Console.WriteLine(reader.ReadToEnd());
}
//using (GZipStream gzip = new GZipStream(Response.GetResponseStream(), CompressionMode.Decompress))
//{
// using (StreamReader reader = new StreamReader(gzip, Encoding.GetEncoding("gb2312")))
// {
// Console.WriteLine(reader.ReadToEnd());
// }
//}
Request.ContentType = "application/x-www-form-urlencoded";
Request.Method = "GET";
//Request.Headers["Accept-Encoding"] = "gzip"; //告知服务器支持gzip解压
WebResponse Response = Request.GetResponse();
using (StreamReader reader = new StreamReader(Response.GetResponseStream(), Encoding.GetEncoding("gb2312")))
{
Console.WriteLine(reader.ReadToEnd());
}
//using (GZipStream gzip = new GZipStream(Response.GetResponseStream(), CompressionMode.Decompress))
//{
// using (StreamReader reader = new StreamReader(gzip, Encoding.GetEncoding("gb2312")))
// {
// Console.WriteLine(reader.ReadToEnd());
// }
//}
评论: 0 | 引用: 0 | 查看次数: 6674
发表评论
请登录后再发表评论!