<httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="0">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
Anything that starts with the MIME type of text or message will be compressed, but it maps only a single javascript mime type to be compressed, application/javascript. However, the default mappings in the ApplicationHost.config are set to:
<mimeMap fileExtension=".jpg" mimeType="image/jpeg" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
<mimeMap fileExtension=".jsx" mimeType="text/jscript" />
As you can see, the MIME type for JavaScript files is set to application/x-javascript, which is not the same as the default in the compression section above. To solve this, you need the add the MIME type application/javascript, to your Web.config.
<system.webServer>
...
<staticContent>
<remove fileExtension=".js" />
<mimeMap fileExtension=".js" mimeType="application/x-javascript" />
</staticContent>
</system.webServer>
No comments:
Post a Comment