【问题标题】:IIS 7.5 Compression creates compressed file but returns the non-compressed oneIIS 7.5 压缩创建压缩文件但返回非压缩文件
【发布时间】:2015-05-04 05:24:59
【问题描述】:

我在 IIS 7.5 中设置压缩时遇到问题。在“%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files”文件夹中有我的压缩文件,但浏览器会收到原始文件。即使使用 Ctrl + F5 一次又一次地刷新页面。此外,我在 Chrome、FF 和 IE 中对此进行了测试(没有“Content-Encoding: gzip”-header)。浏览器正在发送“Accept-Encoding:gzip, deflate, sdch”-header。有人可以给我一个提示吗?

这是我到目前为止所做的:

1) 更改了 appicationHost.config

<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

2) 在cmd中执行如下命令

C:\Windows\System32\inetsrv\appcmd.exe unlock config /section:system.webServer/serverRuntime

3) 在 web.config 中添加以下内容

<system.webServer>
  <serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="10:00:00" />
  <httpCompression> 
    <staticTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/javascript" enabled="true" /> 
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="image/jpeg" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
    </staticTypes> 
      <dynamicTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/javascript" enabled="true" /> 
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="image/jpeg" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
    </dynamicTypes> 
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" /> 
  </httpCompression>
</system.webServer>

4) 在 Windows-Feature-Installer 的 Performance-Features 中添加静态和动态压缩功能(希望这样称呼)

5) 在服务器级别启用静态和动态内容的压缩。并禁用了“最小文件大小”设置。

6) 在站点级别启用静态和动态内容的压缩。

编辑 1:添加了完整的标题。

请求标头

Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:web.web
Pragma:no-cache
Referer:http://web.web/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36

响应标头

Accept-Ranges:bytes
Content-Length:385105
Content-Type:application/x-javascript
Date:Tue, 03 Mar 2015 14:09:48 GMT
ETag:"0535c4b155d01:0"
Last-Modified:Tue, 03 Mar 2015 12:58:38 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
X-Powered-By:ASP.NET

【问题讨论】:

  • 您在哪里添加了标题,为什么这很重要?我已经完成了你所拥有的一切,但仍然得到了未压缩的文件。我也关掉了 Eset Anti Virus,不开心。

标签: asp.net iis http-compression


【解决方案1】:

我找到了问题的根源。

我禁用了 Kaspersky AntiVirus,一切正常。

我不知道为什么这会对此产生影响,但也许有一天这会对某人有所帮助。

编辑 1

在使用卡巴斯基服务器版本的服务器上,一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 2010-09-05
    • 2013-03-09
    • 1970-01-01
    • 1970-01-01
    • 2010-12-14
    • 1970-01-01
    相关资源
    最近更新 更多