Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 为什么不是';IIS压缩识别我的集mime类型?_Asp.net_Azure_Iis_Gzip - Fatal编程技术网

Asp.net 为什么不是';IIS压缩识别我的集mime类型?

Asp.net 为什么不是';IIS压缩识别我的集mime类型?,asp.net,azure,iis,gzip,Asp.net,Azure,Iis,Gzip,我正在将ASP.NET 5/MVC 6 web应用程序发布到基本Azure实例。默认情况下,我的CSS返回gzip编码,但我的javascript不是 为了诊断这个问题,我添加了一个web.config,然后部署到我的webroot: <configuration> <system.webServer> <httpCompression> <staticTypes> &

我正在将ASP.NET 5/MVC 6 web应用程序发布到基本Azure实例。默认情况下,我的CSS返回gzip编码,但我的javascript不是

为了诊断这个问题,我添加了一个
web.config
,然后部署到我的webroot:

<configuration>
    <system.webServer>
        <httpCompression>
            <staticTypes>
                <clear />
            </staticTypes>
            <dynamicTypes>
                <clear />
            </dynamicTypes>
        </httpCompression>
    </system.webServer>
</configuration>
现在一切都是gzip编码的;我的css、javascript、html、webfonts、SVG等

接下来,我将其仅限于文本编码:

<staticTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</dynamicTypes>
我已经检查并再次检查我的javascript是否确实作为
application/javascript
返回。为了更好地衡量,我还包括了uft-8变体

显然,我的
web.config
在某种程度上受到尊重,因为我可以完全关闭它。显然,IIS能够压缩javascript和更多内容,因为我可以完全打开它。我的配置中缺少什么使我无法仅设置要压缩的特定mime类型


编辑:

我尝试了以下方法,将星星添加到mime类型,该类型现在可以工作了:

<staticTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</dynamicTypes>


显然,有一些尾随字符串导致mime类型在结尾没有星号的情况下不匹配,但我不确定它是什么。它没有通过回应。有人知道这个神秘的字符串可能来自什么吗?

尝试设置
staticCompressionIgnoreHitFrequency='True'

这是文档中httpCompression节点的一部分:

如果为True,则禁用仅当静态文件在一段时间内被命中一定次数时才压缩该文件的行为

还有一些其他设置可以控制何时打开或关闭静态压缩


from:

我已经点击了足够的内容,可以在上述所有情况下触发压缩。此外,这并不能解释使用
'*/*'
时的压缩。我已经在问题中添加了其他信息。
<staticTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="application/javascript; charset=utf-8" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript" enabled="true" />
    <add mimeType="application/javascript; charset=utf-8" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</staticTypes>
<dynamicTypes>
    <clear />
    <add mimeType="text/*" enabled="true" />
    <add mimeType="application/javascript*" enabled="true" />
    <add mimeType="*/*" enabled="false" />
</dynamicTypes>