How do I disable gzip compression for flv files in IIS 7 with runAllManagedModulesForAllRequests set to true?

断了今生、忘了曾经 提交于 2019-12-23 10:00:11

问题


I have an ASP.NET 3.5 Website that is running on IIS 7 and I would like to have my static content (like css files, javascript files, etc) gzip compressed as well as my dynamic content (.net pages). The problem is that I need to make sure flv files (flash video files) are not gzip compressed because that causes problems with the flash video player I'm using, Flowplayer.

I've added the following line to my web.config which enables compression, but then my flv files are also being gzip compressed:

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

I've tried to add the following to my web.config, but it did not change anything:

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

I have to turn off doDynamicCompression for the flv files not to be gzip compressed. I think that it is treating flv files as dynamic content because I have runAllManagedModulesForAllRequests="true" in my web.config (which I need for some of the things I'm doing with routing).

In summary, how do I disable gzip compression for flv files?


回答1:


I think the best thing to do is to manually manage what is getting gzip'd. Sometimes what is gzip'd can actually increase in size, like a swf, which is what I just ran into. Previously my application.config had this block in it, and after I removed the shockwave mime type swf's stopped compressing

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

This is in my application config in windows\system32\intersrv\config\application.config but I am pretty sure you can do this per website in your web.config under system.webserver.

All I had to do for me was to remove the shockwave mime type and it stopped getting compressed but all other valid mime types were.



来源:https://stackoverflow.com/questions/4669833/how-do-i-disable-gzip-compression-for-flv-files-in-iis-7-with-runallmanagedmodul

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