asp.net mvc - some files are not gzipped

a 夏天 提交于 2019-12-08 03:47:42

问题


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" />

回答1:


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>


来源:https://stackoverflow.com/questions/9336860/asp-net-mvc-some-files-are-not-gzipped

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!