4

Does anyone know why the following web.conig changes will NOT work:

<httpCompression>
  <staticTypes>
    <add mimeType="application/javascript" enabled="true"/>
  </staticTypes>
<dynamicTypes>
  <add mimeType="application/javascript" enabled="true"/>
</dynamicTypes>
</httpCompression>

After i added javascript files were still not being compressed (gzip). I thrased around for a couple days because i really didn't know what the problem was at first but now i do. If i change the applicationhost.config directly though it does work:

  <httpCompression directory="%TEMP%\iisexpress\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%IIS_BIN%\gzip.dll" />
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

It would be MUCH easier to change your web.config then trying to figure out what web servers applicationhost.config file is incorrect but unfortunately it doesn't work

That being said IIS Express is setup "incorrectly" by default. It gives javascript files a mimetype of "application/javascript" but only compresses javascript files that come across as "application/x-javascript". I don't know if IIS (not express) ever comes defaulted this way.

coding4fun
  • 8,038
  • 13
  • 58
  • 85
  • This question appears to be off-topic because it is about web server configuration rather than programming. webmasters.stackexchange.com might be a better place to ask. – Jim Lewis Sep 17 '14 at 03:46

1 Answers1

0

You could try adding the doDynamicCompression attribute with a value of true to the urlCompression attribute.

<urlCompression doDynamicCompression="true" />
Scott Munro
  • 13,369
  • 3
  • 74
  • 80