1

Even though this has been ask numerous times I still haven't found a working solution on StackOverflow:

I've created an angular SPA with the angular cli. This gives me .html / .js files which I have deployed to azure. Now I want azure to serve these files gzip encoded. In order to do that I've created a 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>

But this doesn't serve any files gzipped.

I've also tried it with this config:

<?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>

same result...

Does anyone know how I can get azure to serve these static files gzipped?

Domenic
  • 708
  • 1
  • 9
  • 23

2 Answers2

0

Have you tried doing an XDT transform? as described here: 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>
Byron Tardif
  • 1,172
  • 6
  • 16
  • This doesn't work as well. Also, I don't really get the idea behind that solution. I've uploaded a web.config to azure which already has all the needed elements. How would a to-be-transformed-xml be better than a final (and therefore already transformed) xml? – Domenic Sep 01 '17 at 17:45
  • Before someone asks: Yes, we don't run a free or shared WebApp. We use the standard app model – Domenic Sep 01 '17 at 17:46
0

I haven't had a lot of luck enabling GZip compression either. What I eventually did was take my static Angular files, put them into a .NET bundle, append a calculated hash to the URL for cache busting, then push them into an Azure CDN. I was able to get the CDN to serve the files using GZip compression.

Rob Reagan
  • 7,313
  • 3
  • 20
  • 49