繁体   English   中英

动态压缩时如何修复err_content_decoding_failed?

[英]how to fix err_content_decoding_failed when dynamic compressing?

我正在开发一个ASP.Net网站,目前正在优化它。 我正在尝试为其启用动态内容压缩,但它无法正常工作。

我明白了

错误330(net :: ERR_CONTENT_DECODING_FAILED):未知错误。

  • 在我的开发环境中,它运行良好。

    • 我已经在发布模式下构建了项目我添加了动态内容压缩模块,启用了动态内容压缩并检查了这是我收到的内容。
  • 我有安装了IIS的AWS EC2服务器windows 2008 R2。

    • 我已经在发布模式下构建了项目,并将其发布到我部署到服务器的文件夹中。
    • 我尝试使用与开发人员计算机上相同的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" />

有人知道可能出现什么问题吗?

提前致谢。

编辑:尝试通过fiddler运行请求并得到响应:“内容无法解压缩。

GZip标头中的幻数不正确。 确保你传入GZip流。“

我们遇到此问题导致IIS临时压缩文件由于磁盘空间不足而损坏/截断:

  1. 运行inetmgr
  2. 转到机器, 压缩功能
  3. 删除Cache目录的内容

我的一位同事有同样的问题。

他正在使用非标准应用程序池标识运行他的应用程序。 为了解决这个问题,我将称之为SomeOtherApplicationPoolIdentity

问题是它缺少对其缓存目录中的子文件夹的权限(要查看IIS使用的缓存目录,请转到IIS管理器,单击顶级树节点,单击“压缩”;默认情况下,它是%SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files ):

在此输入图像描述

%SystemDrive%\\inetpub\\temp\\IIS Temporary Compressed Files ,他缺少一个名为SomeOtherApplicationPoolIdentity的子文件夹的权限,该子文件夹根据其应用程序池标识进行了上下文命名,因此他只是从该子文件夹继承父文件夹的权限文件夹和它工作,因为父文件夹通常授予IIS_IUSRSSYSTEMAdministrators和本地管理用户帐户的权限。

尝试指定dynamicCompressionBeforeCache =“false”

我试图使用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

dynamicCompressionBeforeCache属性指定IIS是否将动态压缩尚未缓存的内容。 当dynamicCompressionBeforeCache属性为true时,IIS会在第一次发出请求时动态压缩响应,并对内容进行排队以进行压缩。 后续请求将动态提供,直到压缩响应已添加到缓存目录。 将压缩响应添加到缓存目录后,缓存的响应将发送到客户端以用于后续请求。 当dynamicCompressionBeforeCache为false时,IIS将返回未压缩的响应,直到将压缩响应添加到缓存目录。

注意:如果在刷新输出缓存响应时dynamicCompressionBeforeCache属性为true,则在将响应放入输出缓存之前不会执行动态压缩。 但是,如果doDynamicCompression属性为true,则在使用响应填充输出缓存后仍将发生动态压缩。

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

暂无
暂无

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

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