Static compression in IIS does not work for htm, js files

I am trying to configure IIS 7.5 to compress static htm and js files. Does anyone know why this is not working for me? Here is my web.config for the website:

<httpCompression> <dynamicTypes> <add mimeType="text/*" enabled="true" /> <add mimeType="message/*" enabled="true" /> <add mimeType="application/x-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="*/*" enabled="false" /> </staticTypes> </httpCompression> <urlCompression doStaticCompression="true" doDynamicCompression="false" /> 

Compression starts when I set doDynamicCompression to true. But I can not use this option because it is disabled on my hosting.

Thanks.

+4
source share
3 answers
+2
source

What makes you think compression is not working? Check event logs. The Static Compression module sometimes throws an error saying that the directory used is not valid (mainly because it needs write permissions).

Double check with Fiddler or another HTTP debugging tool to ensure that the client sends Accept-Encoding from GZIP / Deflate.

+3
source

I removed mimeType = "application / x-javascript" from dynamicTypes, but left it in staticTypes. This allowed me to disable dynamicCompression, but javascript is still compressed.

I read several posts that suggest that having the same mimeType in dynamic and static values ​​in dynamic wins. When dynamicCompression is turned off, but there is a match in the dynamic type, javascript is treated as dynamic and therefore turned off.

This does not explain why CSS works because mimeType = "text /" is in both places. IIS should be better at defining dynamic or static content when it comes to CSS, or any text.

+1
source

Source: https://habr.com/ru/post/1346249/


All Articles