tug*_*erk 57 .net asp.net iis gzip iis-7.5
我试图支持IIS下的静态文件的GZip压缩(默认情况下应该启用但不能)但到目前为止还没有工作.这是<system.webServer>Web应用程序的web.config文件中节点下的部分;
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" />
Run Code Online (Sandbox Code Playgroud)
我尝试使用谷歌浏览器.这是请求标题;
接受:text/html,application/xhtml + xml,application/xml; q = 0.9,/ ; q = 0.8
接收字符集:ISO-8859-1,utf-8; Q = 0.7,*; Q = 0.3
接受编码:gzip,放气,SDCH
接受语言:EN-US,EN; Q = 0.8
缓存控制:无缓存
连接:保持活跃
主持人:我-网站网址
附注:无缓存
用户代理:Mozilla/5.0(Windows NT 6.0)AppleWebKit/534.30(KHTML,类似Gecko)Chrome/12.0.742.122 Safari/534.30
这些是响应标题;
接受-范围:字节
内容长度:232651
内容类型:应用程序/ x-的JavaScript
日期:2011年8月4日星期四08:58:19 GMT
ETag的: "a69135734a50cc1:0"
Last-Modified:Mon,01 Aug 2011 12:56:37 GMT
服务器:Microsoft-IIS/7.5
X-已启动方式:ASP.NET
我检查了applicationHost.config文件,发现了一些如下节点;
----
<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />
----
<section name="urlCompression" overrideModeDefault="Allow" />
----
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
----
<urlCompression />
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
Bra*_*000 42
经过大量的搜索,我终于找到了什么压缩工作在我的IIS 7.5上.首先,IIS不会压缩文件,除非它经常加载.这提出了一个问题"IIS经常考虑什么?" 嗯,默认值是每10秒2次.哎呀!
可以在web.config中更改此设置,但需要先在applicationHost.config中解锁该部分.以下是命令:
首先解锁部分:
C:\ Windows\System32\inetsrv\appcmd.exe解锁配置/section:system.webServer/serverRuntime
配置路径"MACHINE/WEBROOT/APPHOST"中的未锁定部分"system.webServer/serverRuntime".
完成后,编辑web.config文件并添加serverRuntime元素:
<?xml version ="1.0"encoding ="UTF-8"?>
<configuration>
<system.webServer>
<serverRuntime frequentHitThreshold ="1"frequentHitTimePeriod ="10:00:00"/>
...
在这种情况下,我将其设置为在10小时内点击一次文件.您可以根据需要调整值.这是解释serverRuntime元素的文档:
http://www.iis.net/configreference/system.webserver/serverruntime
我希望这也有助于你的压缩工作.
注意:您还可以在applicationHost.config文件中设置serverRuntime元素,但我选择在web.config中更改它,因为我们有许多服务器和具有各种站点的服务器场,并且我更容易控制它从这个粒度级别.
Eri*_*Law 29
要记住的一件事是,第一个命中通常会立即返回未压缩,但会旋转一个线程以在后台压缩文件,以便为将来的请求提供压缩服务.
此外,您是否尝试过使用其他客户端(例如IE)?
我花了一些时间才弄明白这一点.在applicationHost.config文件中的system.webServer/serverRuntime节点上将frequentHitThreshold属性设置为1应该可以解决问题,如http://www.iis.net/ConfigReference/system.webServer/serverRuntime中所述.
您可以通过以管理员身份执行以下命令来执行此操作:
%windir%\system32\inetsrv\appcmd set config /section:serverRuntime /frequentHitThreshold:1 /commit:apphost
Run Code Online (Sandbox Code Playgroud)
一句警告 - "频繁命中"概念似乎并不特定于压缩.我不知道设置这个是否会产生其他后果!
| 归档时间: |
|
| 查看次数: |
45807 次 |
| 最近记录: |