2017-09-01 26 views
1

尽管这已经问过无数次我还没有发现在计算器上一个有效的解决方案:Azure的Web应用程序简单的HTML/JS的gzip

我已经创建了角CLI角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> 

相同的结果...

有谁知道我怎么能得到蔚蓝服务gzip压缩这些静态的文件?

+0

请参阅:https://stackoverflow.com/questions/34006236/azure-web-app-not-using-gzip-compression –

+0

是的,我已经读过这个线程。不为我提供解决方案以及... – Domenic

回答

0

您是否尝试过进行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> 
+0

这不起作用。 另外,我并没有真正了解这个解决方案背后的想法。我已经上传了一个web.config到azure,它已经有了所有需要的元素。如何将被转换的xml比最终(因此已经转换)的xml更好? – Domenic

+0

之前有人问:是的,我们不运行免费或共享的Web应用程序。我们使用标准的应用程序模型 – Domenic

0

我还没有很多运气启用gzip压缩的任何一个。我最终做的是拿走我的静态Angular文件,将它们放入一个.NET包中,将一个计算出来的散列附加到缓存清除的URL上,然后将它们推送到一个Azure CDN中。我能够让CDN使用GZip压缩来提供文件。

相关问题