Azure Web App不使用GZip压缩 [英] Azure Web App Not Using GZip Compression

查看:98
本文介绍了Azure Web App不使用GZip压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用WebPageTest来测试我的Azure Web应用程序(ASP.Net vNext Web API/Angular)的性能.对于压缩传输"和缓存静态内容",我都得到了F.

I was using WebPageTest to test the performance of my Azure Web App (ASP.Net vNext Web API/Angular). I got an F for both "Compress Transfer" and "Cache Static Content".

在搜索StackOverflow和Google之后,我将以下内容添加到了web.config中:

After searching StackOverflow and Google, I added the following to my web.config:

<urlCompression doStaticCompression="true" doDynamicCompression="true" />
    <httpCompression>
      <dynamicTypes>
        <clear />
        <remove mimeType="*/*" />
        <add enabled="true" mimeType="text/*"/>
        <add enabled="true" mimeType="message/*"/>
        <add enabled="true" mimeType="application/x-javascript"/>
        <add enabled="true" mimeType="application/javascript"/>
        <add enabled="true" mimeType="application/json"/>
        <add enabled="false" mimeType="*/*"/>
        <add enabled="true" mimeType="application/atom+xml"/>
        <add enabled="true" mimeType="application/atom+xml;charset=utf-8"/>
      </dynamicTypes>
      <staticTypes>
        <clear />
        <remove mimeType="*/*" />
        <add enabled="true" mimeType="text/*"/>
        <add enabled="true" mimeType="message/*"/>
        <add enabled="true" mimeType="application/javascript"/>
        <add enabled="true" mimeType="application/atom+xml"/>
        <add enabled="true" mimeType="application/xaml+xml"/>
        <add enabled="true" mimeType="application/json"/>
        <add enabled="false" mimeType="*/*"/>
      </staticTypes>
    </httpCompression>

<staticContent>
      <!-- Set expire headers to 30 days for static content-->
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>

重新部署我的Web应用程序之后,我重新运行了测试,但是我仍然为他们两个都获得了F.即使我已将这些设置添加到web.config中,Azure Web App仍未兑现它们.

After redeploying my Web App, I re-ran the test and I am still getting an F for both of them. Even though I have added these settings to web.config, it does not appear that Azure Web App is honoring them.

此外,我发现某些Web应用程序层不允许压缩,但是我在S2上运行,并且我验证了它确实允许压缩.

Also, I found out that some Web App tiers do not allow compression but I am running on an S2 and I verified that it does allow compression.

任何帮助将不胜感激!

谢谢!

推荐答案

gzip压缩.您可以在站点LocalSiteRoot/Config/applicationhost.config中查看规则.查看响应标头(可以使用开发人员工具轻松完成),应确认正在使用gzip.您的站点加载的资源之一可能没有被压缩,这导致WebPageTest失败.我将看一下网络捕获和响应头,看看是否可以找到有问题的资源.

gzip compression is enabled by default for Azure Web Apps. You can see the rules in your sites LocalSiteRoot/Config/applicationhost.config. Looking at the response headers (which can easily be done with developer tools) should confirm that gzip is being used. It is possible that one of the resources that your site loads is not compressed, and this is causing the WebPageTest to fail. I would look at a network capture and the response headers, and see if you can find the offending resources if you're concerned.

要转到本地站点根目录,可以使用FTP,也可以转到https://.scm.azurewebsites.net/DebugConsole上的SCM站点,然后单击地球图标.

To go to the local site root, you can use FTP, or go to your SCM site at https://.scm.azurewebsites.net/DebugConsole and then click the globe icon.

我还怀疑您的2个javascript文件没有压缩,因为没有填充Content-Type标头,因此该规则未捕获它,因为它无法识别mimetype.

Also I suspect that your 2 javascript files are not getting compressed since the Content-Type header is not getting populated, so the rule is not capturing it because it does not recognize the mimetype.

这篇关于Azure Web App不使用GZip压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆