Mvc 4脚本捆绑和GZip

Yav*_*sta 5 iis asp.net-mvc gzip bundle

我已经将我网站上的所有脚本添加到非常大的包中(大约700kb).现在我希望IIS能够对它进行gzip,但我不能.

我已经尝试过我在这里和网上找到的所有内容,但没有任何帮助.静态*.js文件使用gzip,但不完整包.

有什么解决方案吗?

Cyb*_*axs 5

检查IIS中的动态压缩.必须为IIS和您的网站启用它.您还必须在applicationHost.config中拥有有效的配置.

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <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>
Run Code Online (Sandbox Code Playgroud)

重要说明: Bundling响应的内容类型为text/javascript,因此请检查此类型的配置.