简体   繁体   English

动态压缩时如何修复err_content_decoding_failed?

[英]how to fix err_content_decoding_failed when dynamic compressing?

I'm working on a ASP.Net website, and are currently optimizing it. 我正在开发一个ASP.Net网站,目前正在优化它。 I'm trying to enable dynamic content compression to it, but it won't work. 我正在尝试为其启用动态内容压缩,但它无法正常工作。

I get 我明白了

Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error. 错误330(net :: ERR_CONTENT_DECODING_FAILED):未知错误。

  • On my development environment it works well. 在我的开发环境中,它运行良好。

    • I've built the project in release mode I've added the dynamic content compression module, enabled dynamic content compression and checked that this is what i receive. 我已经在发布模式下构建了项目我添加了动态内容压缩模块,启用了动态内容压缩并检查了这是我收到的内容。
  • I have an AWS EC2 server windows 2008 R2 with IIS installed. 我有安装了IIS的AWS EC2服务器windows 2008 R2。

    • I've built the project in release mode, and publish it to a folder, which i deploy to the server. 我已经在发布模式下构建了项目,并将其发布到我部署到服务器的文件夹中。
    • I've tried with the same web.config file as i have on the developer machine, but no luck there 我尝试使用与开发人员计算机上相同的web.config文件,但没有运气

Added this to web.config: 将此添加到web.config:

<httpCompression
    directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
    dynamicCompressionDisableCpuUsage="90"
    dynamicCompressionEnableCpuUsage="80"
    maxDiskSpaceUsage="100" minFileSizeForComp="2700"
    noCompressionForRange="true"
    sendCacheHeaders="false"
    staticCompressionDisableCpuUsage="100"
    staticCompressionEnableCpuUsage="80"
    >
    <scheme name="gzip"
        dll="%Windir%\system32\inetsrv\gzip.dll" />
    <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
    </dynamicTypes>
    <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/atom+xml" enabled="true" />
        <add mimeType="application/rss+xml" enabled="true" />
        <add mimeType="application/xaml+xml" enabled="true" />
        <add mimeType="application/xml" enabled="true" />
        <add mimeType="image/svg+xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
    </staticTypes>
</httpCompression>
<urlCompression doDynamicCompression="true" />

Anybody have an idea of what could be wrong? 有人知道可能出现什么问题吗?

Thanks in advance. 提前致谢。

EDIT: Tried running the request through fiddler and got the response: "The content could not be decompressed. 编辑:尝试通过fiddler运行请求并得到响应:“内容无法解压缩。

The magic number in GZip header is not correct. GZip标头中的幻数不正确。 Make sure you are passing in a GZip stream." 确保你传入GZip流。“

We encountered this problem caused IIS Temporary Compressed Files which were corrupt/truncated due to the disk running out of space: 我们遇到此问题导致IIS临时压缩文件由于磁盘空间不足而损坏/截断:

  1. Run inetmgr 运行inetmgr
  2. Go to the machine, Compression feature 转到机器, 压缩功能
  3. Delete the contents of the Cache directory 删除Cache目录的内容

A colleague of mine had this exact same problem. 我的一位同事有同样的问题。

He was running his application with a non-standard application pool identity. 他正在使用非标准应用程序池标识运行他的应用程序。 For the sake of this solution I will call that identity SomeOtherApplicationPoolIdentity . 为了解决这个问题,我将称之为SomeOtherApplicationPoolIdentity

The problem was that it was lacking permissions to a sub-folder in his cache directory (to see what cache directory IIS uses, go to the IIS Manager, click the top-level tree node, click on Compression; by default it is %SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files ): 问题是它缺少对其缓存目录中的子文件夹的权限(要查看IIS使用的缓存目录,请转到IIS管理器,单击顶级树节点,单击“压缩”;默认情况下,它是%SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files ):

在此输入图像描述

Inside of %SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files , he was missing permissions for a sub-folder named, SomeOtherApplicationPoolIdentity , contextually named according to his application pool identity, so he just inherited permissions from the parent folder from that sub-folder and it worked, because the parent folder generally grants permissions to the IIS_IUSRS , SYSTEM , Administrators , and local administrative user account. %SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files ,他缺少一个名为SomeOtherApplicationPoolIdentity的子文件夹的权限,该子文件夹根据其应用程序池标识进行了上下文命名,因此他只是从该子文件夹继承父文件夹的权限文件夹和它工作,因为父文件夹通常授予IIS_IUSRSSYSTEMAdministrators和本地管理用户帐户的权限。

try to specify dynamicCompressionBeforeCache="false" 尝试指定dynamicCompressionBeforeCache =“false”

I was trying to use dynamicCompressionBeforeCache="true" because I thought it will cause my cached objects to be saved compressed - so that they can be served as smaller files, but got the same error... 我试图使用dynamicCompressionBeforeCache =“true”因为我认为它会导致我的缓存对象被压缩保存 - 这样它们可以作为较小的文件提供,但是得到了同样的错误......

<!--http://www.iis.net/configreference/system.webserver/urlcompression-->
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="false" />
<httpCompression 
  directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
  dynamicCompressionDisableCpuUsage="90"
  dynamicCompressionEnableCpuUsage="80"
  maxDiskSpaceUsage="100"
  minFileSizeForComp="2700"
  noCompressionForRange="true"
  sendCacheHeaders="false"
  staticCompressionDisableCpuUsage="100"
  staticCompressionEnableCpuUsage="80">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
    <dynamicTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="application/json" enabled="true" />
      <add mimeType="application/xml" enabled="true" />
      <add mimeType="*/*" enabled="false" />
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true" />
      <add mimeType="message/*" enabled="true" />
      <add mimeType="application/javascript" enabled="true" />
      <add mimeType="application/json" enabled="true" />
      <add mimeType="application/atom+xml" enabled="true" />
      <add mimeType="application/rss+xml" enabled="true" />
      <add mimeType="application/xaml+xml" enabled="true" />
      <add mimeType="application/xml" enabled="true" />
      <add mimeType="image/svg+xml" enabled="true" />
      <add mimeType="*/*" enabled="false" />
    </staticTypes>
</httpCompression>

http://www.iis.net/configreference/system.webserver/urlcompression http://www.iis.net/configreference/system.webserver/urlcompression

The dynamicCompressionBeforeCache attribute specifies whether IIS will dynamically compress content that has not been cached. dynamicCompressionBeforeCache属性指定IIS是否将动态压缩尚未缓存的内容。 When the dynamicCompressionBeforeCache attribute is true, IIS dynamically compresses the response the first time a request is made and queues the content for compression. 当dynamicCompressionBeforeCache属性为true时,IIS会在第一次发出请求时动态压缩响应,并对内容进行排队以进行压缩。 Subsequent requests are served dynamically until the compressed response has been added to the cache directory. 后续请求将动态提供,直到压缩响应已添加到缓存目录。 Once the compressed response is added to the cache directory, the cached response is sent to clients for subsequent requests. 将压缩响应添加到缓存目录后,缓存的响应将发送到客户端以用于后续请求。 When dynamicCompressionBeforeCache is false, IIS returns the uncompressed response until the compressed response has been added to the cache directory. 当dynamicCompressionBeforeCache为false时,IIS将返回未压缩的响应,直到将压缩响应添加到缓存目录。

Note: If the dynamicCompressionBeforeCache attribute is true when the output cache response has been flushed, dynamic compression will not be performed before the response is put into the output cache. 注意:如果在刷新输出缓存响应时dynamicCompressionBeforeCache属性为true,则在将响应放入输出缓存之前不会执行动态压缩。 However, if the doDynamicCompression attribute is true, dynamic compression will still occur after the output cache has been filled with the response. 但是,如果doDynamicCompression属性为true,则在使用响应填充输出缓存后仍将发生动态压缩。

我的想法是检查应用程序池用户(如果您有任何特定的)是否拥有目录“%SystemDrive%\\ inetpub \\ temp \\ IIS临时压缩文件”的完全权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM