asp.net mvc的 - 一些文件没有gzip压缩 [英] asp.net mvc - some files are not gzipped
本文介绍了asp.net mvc的 - 一些文件没有gzip压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有趣的是一些静态文件gzip压缩的有些不是(特别ckeditor.js)。可能是什么原因?配置部分如下:
< dynamicTypes>
<添加mime类型=文/ *启用=真/>
<添加mime类型=消息/ *启用=真/>
<添加mime类型=应用程序/ x-JavaScript的启用=真/>
<添加mime类型=应用/ JSON启用=真/>
<添加mime类型=* / *启用=FALSE/>
< / dynamicTypes>
< staticTypes>
<添加mime类型=文/ *启用=真/>
<添加mime类型=消息/ *启用=真/>
<添加mime类型=应用程序/ x-JavaScript的启用=真/>
<添加mime类型=应用程序/原子+ XML启用=真/>
<添加mime类型=应用/ XAML + XML启用=真/>
<添加mime类型=* / *启用=FALSE/>
< / staticTypes>
< / httpCom pression>
< staticContent>
&所述; clientCache cacheControlMaxAge =14.00:00:00cacheControlMode =UseMaxAge/>
< / staticContent>
< urlCom pression doStaticCom pression =真doDynamicCom pression =真dynamicCom pressionBeforeCache =真/>
解决方案
这可能该做断MIME类型映射。使用此:
< httpCom pression>
<清除NAME =gzip的/>
<方案名称=gzip的dynamicCom pressionLevel =9staticCom pressionLevel =9doDynamicCom pression =真doStaticCom pression =真正的DLL =%WINDIR% \\ SYSTEM32 \\ INETSRV \\ gzip.dll/>
< dynamicTypes>
<添加mime类型=文/ *启用=真/>
<添加mime类型=消息/ *启用=真/>
<添加mime类型=应用程序/ JavaScript的启用=真/>
<添加mime类型=应用程序/ x-JavaScript的启用=真/>
<添加mime类型=应用程序/ JavaScript的;字符集= UTF-8启用=真/>
<添加mime类型=* / *启用=真/>
< / dynamicTypes>
< staticTypes>
<添加mime类型=文/ *启用=真/>
<添加mime类型=消息/ *启用=真/>
<添加mime类型=应用程序/ JavaScript的启用=真/>
<添加mime类型=应用程序/ x-JavaScript的启用=真/>
<添加mime类型=应用程序/ JavaScript的;字符集= UTF-8启用=真/>
<添加mime类型=* / *启用=真/>
< / staticTypes>
< / httpCom pression>
< staticContent>
<清除fileExtension = /&GTJS;
< mimeMap fileExtension = mime类型=文/ JavaScript的/&GTJS;
< / staticContent>
Interestingly some static files are gzipped some are not (specifically ckeditor.js). What might be the cause? Config section is below:
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" 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/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
<staticContent>
<clientCache cacheControlMaxAge="14.00:00:00" cacheControlMode="UseMaxAge" />
</staticContent>
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
解决方案
This probably has do to with broken mime type mapping. Use this:
<httpCompression>
<remove name="gzip"/>
<scheme name="gzip" dynamicCompressionLevel="9" staticCompressionLevel="9" doDynamicCompression="true" doStaticCompression="true" dll="%Windir%\system32\inetsrv\gzip.dll"/>
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="application/x-javascript" enabled="true"/>
<add mimeType="application/javascript; charset=utf-8" enabled="true"/>
<add mimeType="*/*" enabled="true"/>
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/javascript" enabled="true"/>
<add mimeType="application/x-javascript" enabled="true"/>
<add mimeType="application/javascript; charset=utf-8" enabled="true"/>
<add mimeType="*/*" enabled="true"/>
</staticTypes>
</httpCompression>
<staticContent>
<remove fileExtension=".js"/>
<mimeMap fileExtension=".js" mimeType="text/javascript"/>
</staticContent>
这篇关于asp.net mvc的 - 一些文件没有gzip压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文