【问题标题】:Cant view gzipped html page on azure app service无法在 azure 应用服务上查看 gzipped html 页面
【发布时间】:2021-03-10 10:44:38
【问题描述】:

我用 gzipper 压缩 HTML 页面,并将文件上传到 azure app 服务。

当从浏览器打开页面 url 时,页面使用 gzip 编码但无法查看页面内容 - 似乎页面未解码

浏览器中返回的页面有 gzip 编码:

浏览器中的结果:

【问题讨论】:

  • 我可能错了,但是 content-Type 应该是 text/html; charset=utf-8 而不是 text/html

标签: node.js angular azure iis gzip


【解决方案1】:

您可以尝试将以下代码添加到您的 web.config 文件中以启用静态和动态内容的压缩。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    <httpCompression>
      <dynamicTypes>
        <clear />
        <add enabled="true" mimeType="text/*"/>
        <add enabled="true" mimeType="message/*"/>
        <add enabled="true" mimeType="application/x-javascript"/>
        <add enabled="true" mimeType="application/javascript"/>
        <add enabled="true" mimeType="application/json"/>
        <add enabled="false" mimeType="*/*"/>
        <add enabled="true" mimeType="application/atom+xml"/>
        <add enabled="true" mimeType="application/atom+xml;charset=utf-8"/>
      </dynamicTypes>
      <staticTypes>
        <clear />
        <add enabled="true" mimeType="text/*"/>
        <add enabled="true" mimeType="message/*"/>
        <add enabled="true" mimeType="application/javascript"/>
        <add enabled="true" mimeType="application/atom+xml"/>
        <add enabled="true" mimeType="application/xaml+xml"/>
        <add enabled="true" mimeType="application/json"/>
        <add enabled="false" mimeType="*/*"/>
      </staticTypes>
    </httpCompression>
  </system.webServer>
</configuration>

这里是参考可能有帮助:Enabling gzip compression on Azure App Service

【讨论】:

  • 我已经在 web.config 文件中添加了压缩但结果还是一样
猜你喜欢
  • 2016-08-08
  • 2021-06-11
  • 2019-04-28
  • 1970-01-01
  • 2021-01-15
  • 1970-01-01
  • 2020-10-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多