启用IIS6的GZIP功能,提高网站打开速度,减少带宽占用
程序员文章站
2022-05-21 11:35:49
所以呀,像我这样的技术人才,都没考虑过使用他,昨天突然看到这个想到,也许对我有用,但从网上找了找,都是一堆手工操作方法,非常麻烦呀,不过以前研究过iis的配置文件:c:\w...
所以呀,像我这样的技术人才,都没考虑过使用他,昨天突然看到这个想到,也许对我有用,但从网上找了找,都是一堆手工操作方法,非常麻烦呀,不过以前研究过iis的配置文件:c:\windows\system32\inetsrv\metabase.xml,所以呀,我知道只要是iis的功能就可以通过修改这个文件来完成,所以呢,就对这个文件下手吧,根据网上提供的修改的地方,在网上搜索了一圈,找到一个类似clickonce 的东西,呵呵,我找的就是这个,所有操作都一键到位,只要执行一段vbs或cmd就配置好了,呵呵。
使用gzip压缩会增大服务器cpu的使用率但可以通过压缩而减少服务器向客户端发送的数据,若使用了gzip压缩iis在向客户端发送数据时会自动检测,如果客户端浏览器支持ie6.0,firefox gzip,则使用gzip压缩后再传送数据,如果不支持,则使用常规方式发送。
所以,总结下他的优缺点,优:压缩传输,速度一般提高2倍。缺:cpu占用会有所提高,不过通过我的一点分析,gzip只是在访问一个页时才会进行压缩,下次如果网页没有变动是不会压缩的,除非是使用压缩动态文件,这得实时的去压缩。
rem setup iiscompressionscheme for deflate
cscript adsutil.vbs set w3svc/filters/compression/deflate/hccompressiondll "%windir%\system32\inetsrv\gzip.dll"
cscript adsutil.vbs set w3svc/filters/compression/deflate/hccreateflags 0
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdynamiccompressionlevel 9
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcfileextensions "htm" "html" "txt" "js" "xml" "css"
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcondemandcomplevel 9
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcpriority 1
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcscriptfileextensions "asp" "dll" "exe" "aspx" "asmx"
rem setup iiscompressionscheme for gzip
cscript adsutil.vbs set w3svc/filters/compression/gzip/hccompressiondll "%windir%\system32\inetsrv\gzip.dll"
cscript adsutil.vbs set w3svc/filters/compression/gzip/hccreateflags 1
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdynamiccompressionlevel 9
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcfileextensions "htm" "html" "txt" "js" "xml" "css"
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcondemandcomplevel 9
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcpriority 1
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcscriptfileextensions "asp" "dll" "exe" "aspx" "asmx"
rem setup iiscompressionschemes parameters
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccachecontrolheader max-age=86400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccompressionbuffersize 102400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccompressiondirectory "%windir%\iis temporary compressed files"
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdodiskspacelimiting false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcexpiresheader "wed, 01 jan 1997 12:00:00 gmt"
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcfilesdeletedperdiskfree 256
cscript adsutil.vbs set w3svc/filters/compression/parameters/hciobuffersize 102400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcmaxdiskspaceusage 0
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcmaxqueuelength 1000
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcminfilesizeforcomp 1
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforhttp10 false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforproxies false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforrange false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcsendcacheheaders false
iisreset
以上是方法adsutil.vbs不一定人人都能找到,所以提供完整下载地址:
使用gzip压缩会增大服务器cpu的使用率但可以通过压缩而减少服务器向客户端发送的数据,若使用了gzip压缩iis在向客户端发送数据时会自动检测,如果客户端浏览器支持ie6.0,firefox gzip,则使用gzip压缩后再传送数据,如果不支持,则使用常规方式发送。
所以,总结下他的优缺点,优:压缩传输,速度一般提高2倍。缺:cpu占用会有所提高,不过通过我的一点分析,gzip只是在访问一个页时才会进行压缩,下次如果网页没有变动是不会压缩的,除非是使用压缩动态文件,这得实时的去压缩。
复制代码 代码如下:
rem setup iiscompressionscheme for deflate
cscript adsutil.vbs set w3svc/filters/compression/deflate/hccompressiondll "%windir%\system32\inetsrv\gzip.dll"
cscript adsutil.vbs set w3svc/filters/compression/deflate/hccreateflags 0
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcdynamiccompressionlevel 9
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcfileextensions "htm" "html" "txt" "js" "xml" "css"
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcondemandcomplevel 9
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcpriority 1
cscript adsutil.vbs set w3svc/filters/compression/deflate/hcscriptfileextensions "asp" "dll" "exe" "aspx" "asmx"
rem setup iiscompressionscheme for gzip
cscript adsutil.vbs set w3svc/filters/compression/gzip/hccompressiondll "%windir%\system32\inetsrv\gzip.dll"
cscript adsutil.vbs set w3svc/filters/compression/gzip/hccreateflags 1
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcdynamiccompressionlevel 9
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcfileextensions "htm" "html" "txt" "js" "xml" "css"
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcondemandcomplevel 9
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcpriority 1
cscript adsutil.vbs set w3svc/filters/compression/gzip/hcscriptfileextensions "asp" "dll" "exe" "aspx" "asmx"
rem setup iiscompressionschemes parameters
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccachecontrolheader max-age=86400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccompressionbuffersize 102400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hccompressiondirectory "%windir%\iis temporary compressed files"
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdodiskspacelimiting false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdodynamiccompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdoondemandcompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcdostaticcompression true
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcexpiresheader "wed, 01 jan 1997 12:00:00 gmt"
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcfilesdeletedperdiskfree 256
cscript adsutil.vbs set w3svc/filters/compression/parameters/hciobuffersize 102400
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcmaxdiskspaceusage 0
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcmaxqueuelength 1000
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcminfilesizeforcomp 1
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforhttp10 false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforproxies false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcnocompressionforrange false
cscript adsutil.vbs set w3svc/filters/compression/parameters/hcsendcacheheaders false
iisreset
以上是方法adsutil.vbs不一定人人都能找到,所以提供完整下载地址: