[英]gzip compression in Windows Azure Websites
是否可以在简单的Azure网站上启用gzip压缩? 如果是这样,怎么办呢? 在Azure网站上应用gzip时有什么需要考虑的吗?
我刚刚查看了我的一个天蓝色网站,它确实看起来像gzip正在工作。 我的web.config中没有任何特殊内容,所以我认为默认情况下必须启用它。
根据@ DavideB对已接受答案的评论,我发现您可以通过web.config为Azure / IIS配置此项。 [ MSDN来源 ]
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%windir%\system32\inetsrv\gzip.dll"
doDynamicCompression="true" doStaticCompression="true"
staticCompressionLevel="7" dynamicCompressionLevel="7" />
<staticTypes>
<add mimeType="*/*" enabled="true" />
</staticTypes>
<dynamicTypes>
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
</httpCompression>
</system.webServer>
</configuration>
请注意:
这只适用于Azure,或者安装了正确功能的IIS(例如,如果您使用的是IISExpress,或者说您运气不好,请参阅文章了解正确的功能以及本地测试的配置说明)。
静态和动态资源的压缩是独立配置的,具有单独的默认值; 在实践中,你应该比我更仔细地配置你的mimetypes和压缩级别。
压缩级别介于0和10之间,其中0 ==关闭,10 ==最大; 在这里,我将我的设置为7,理由是它可能是CPU使用和压缩之间的良好折衷。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.