【问题标题】:How do I disable gzip compression for flv files in IIS 7 with runAllManagedModulesForAllRequests set to true?如何在 runAllManagedModulesForAllRequests 设置为 true 的情况下禁用 IIS 7 中 flv 文件的 gzip 压缩?
【发布时间】:2011-06-07 21:02:36
【问题描述】:

我有一个在 IIS 7 上运行的 ASP.NET 3.5 网站,我希望将我的静态内容(如 css 文件、javascript 文件等)gzip 以及我的动态内容(.net 页面)压缩。问题是我需要确保 flv 文件(flash 视频文件)没有经过 gzip 压缩,因为这会导致我使用的 flash 视频播放器出现问题,Flowplayer

我已在启用压缩的 web.config 中添加以下行,但随后我的 flv 文件也被 gzip 压缩:

<urlCompression doStaticCompression="true" doDynamicCompression="true" />

我尝试将以下内容添加到我的 web.config,但它没有改变任何内容:

<httpCompression>
    <staticTypes>
        <remove mimeType="video/x-flv"/>
    </staticTypes>
    <dynamicTypes>
        <remove mimeType="video/x-flv"/>
    </dynamicTypes>
</httpCompression>

我必须关闭 doDynamicCompression 才能使 flv 文件不被 gzip 压缩。我认为它将 flv 文件视为动态内容,因为我在 web.config 中已 runAllManagedModulesForAllRequests="true" (我在路由中做的一些事情需要它)。

总之,如何禁用 flv 文件的 gzip 压缩?

【问题讨论】:

  • 这就是我相信你想要的&lt;add mimeType="video/x-flv" enabled="false" /&gt;注意,我也认为它只能在IIS7的ApplicationHost.config级别完成。

标签: c# asp.net iis-7 web-config gzip


【解决方案1】:

我认为最好的办法是手动管理 gzip 文件。有时 gzip'd 的大小实际上会增加,就像我刚刚遇到的 swf 一样。以前我的application.config 里面有这个块,在我删除了冲击波 mime 类型 swf 后停止压缩

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <dynamicTypes>
                <clear />
                <add mimeType="text/*" enabled="true" />
                <add mimeType="message/*" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true" />
                <add mimeType="application/x-amf" enabled="true" />
                <add mimeType="application/json" enabled="true" />
                <add mimeType="application/json; charset=utf-8" enabled="true" />
                <add mimeType="application/x-shockwave-flash" enabled="true" /> <!-- notice the swf mime type -->
                <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <staticTypes>
                <clear />
                <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="application/x-shockwave-flash" enabled="true" /> <!-- notice the swf mime type -->
                <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

这是在windows\system32\intersrv\config\application.config 的我的应用程序配置中,但我很确定您可以在system.webserver 下的web.config 中为每个网站执行此操作。

我所要做的就是删除冲击波 mime 类型,它不再被压缩,但所有其他有效的 mime 类型都被压缩了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-23
    • 2013-12-23
    • 2011-07-20
    • 2013-08-31
    • 2014-07-07
    • 2011-08-05
    相关资源
    最近更新 更多