Azure WebApp 简单 Html/JS gzip

标签 azure gzip azure-web-app-service

尽管这个问题已经被问过很多次了,但我仍然没有在 StackOverflow 上找到可行的解决方案:

我使用 Angular cli 创建了 Angular SPA。这给了我已部署到 azure 的 .html/.js 文件。 现在我希望 azure 为这些 gzip 编码的文件提供服务。 为了做到这一点,我创建了一个 web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <httpCompression
              directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
           <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        </httpCompression>
        <urlCompression doStaticCompression="true" doDynamicCompression="false" />
    </system.webServer>
</configuration>

但这不提供任何 gzip 压缩的文件。

我也尝试过这个配置:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <urlCompression doStaticCompression="true" doDynamicCompression="false" />
        <httpCompression>
            <staticTypes>
                <clear />
                <remove mimeType="*/*" />
                <add enabled="true" mimeType="text/*"/>
                <add enabled="true" mimeType="message/*"/>
                <add enabled="true" mimeType="application/javascript"/>
                <add enabled="true" mimeType="application/x-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>
</configuration>

相同的结果...

有谁知道如何让 azure 提供这些 gzip 压缩的静态文件?

最佳答案

您是否尝试过进行 XDT 转换?如此处所述: https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <httpCompression>
      <dynamicTypes>
        <add mimeType="application/foo" enabled="true" xdt:Transform="Insert" />
      </dynamicTypes>
    </httpCompression>
  </system.webServer>
</configuration>

关于Azure WebApp 简单 Html/JS gzip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46001883/

相关文章:

azure - 是否可以使用 RBAC 允许对应用服务的应用程序设置进行只读访问?

java - 获取 GZIPped 文件属性(如 'gzip -l' ,基本上是压缩率)

python - 我可以用 Pandas 附加到压缩流吗?

azure - 如何使用 terraform 在 azure api 管理中的所有 API 级别启用应用程序洞察?

Azure Kubernetes 服务 : Image Pull Error (Authentication) even though ImagePullSecret was added in CD pipeline

android - 模块依赖于一个或多个 Android 库,但在使用 VS 2017 构建 Cordova 应用程序时出现 Jar 错误

ios - 下载 gzip 文件时,在 AFNetworking 3.1.0 下不会调用 downloadTaskWithRequest 中的 downloadProgress block

azure - 我们的 ASP.NET core RC1 应用程序停止工作然后又开始工作

azure - 在 ASP.NET 5 MVC 6 中提供静态文件

java - 部署后访问 azure webservice 的 url