【问题标题】:Gzip CSS Compression ASP.NET MVCGzip CSS 压缩 ASP.NET MVC
【发布时间】:2021-07-28 09:45:57
【问题描述】:

使用 IIS10、ASP NET MVC 5

我在 IIS 中启用了动态和静态压缩,并从 Server Maanger 安装了这两个功能。我将以下内容添加到我的 web.config 中:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
    <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>
    
<urlCompression doStaticCompression="true" doDynamicCompression="true" />

css 文件似乎以 gzip 压缩格式提供,并且响应标头包含:

content-encoding:gzip

但是,当在浏览器上呈现时,css 文件并未被注册(即未应用任何样式)。

有没有我遗漏的步骤?

【问题讨论】:

    标签: asp.net-mvc iis gzip


    【解决方案1】:

    确保已安装动态内容压缩功能和静态内容压缩。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-13
    • 1970-01-01
    • 1970-01-01
    • 2017-07-08
    • 2010-09-06
    • 1970-01-01
    • 2010-11-12
    • 2011-04-05
    相关资源
    最近更新 更多