如何在IIS7使用MVC3当我启用gzip COM pression? [英] How do I enable gzip compression when using MVC3 on IIS7?

查看:126
本文介绍了如何在IIS7使用MVC3当我启用gzip COM pression?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道如何启用gzip COM pression在MVC 3?我使用的IIS7。

谷歌浏览器审计的结果是:


  

      
  1. 启用Gzip COM pression(4)

  2.   
  3. 的COM pressing用gzip以下资源可以用约三分之二(〜92.23KB)传输量减少:

  4.   
  5. / MYDOMAIN /可以节省〜1.53KB

  6.   
  7. jQuery的-1.4.4.min.js可以节省〜51.35KB

  8.   
  9. Cufon.js可以节省〜11.89KB

  10.   
  11. Futura.js可以节省〜27.46KB

  12.   


解决方案

您可以通过的web.config 文件中配置COM pression如下:

 < system.webServer>
    < urlCom pression doStaticCom pression =真doDynamicCom pression =真/>
< /system.webServer>

您可以找到在此配置元素的文档<一个href=\"http://www.iis.net/ConfigReference/system.webServer/urlCom$p$pssion\">iis.net/ConfigReference.这是相当于


  1. 打开Internet信息服务(IIS管理器)

  2. 通过左边的树视图导航,直到你找到你要修改的虚拟目录

  3. 选择适当的虚拟目录,以便在右侧窗格中的标题变成称虚拟目录的名称。

  4. 在右侧窗格中选择的COM pressionIIS下

  5. 滴答两个选项,选择应用下最右侧操作。

请注意:(正如在评论中指出)的你需要确保HTTP动态的COM pression安装,否则设置 doDynamicCom pression =真将不会有任何效果。要做到这一点最快捷的方法是:


  1. 启动>键入 optionalfeatures (这是去的打开Windows功能打开或关闭窗口中的最快的方法)

  2. 导航到Internet Information Services>万维网服务>性能特点,在Windows功能树状

  3. 确保动态内容的COM pression被勾选

  4. 单击确定,等待,而Windows上安装的组件

Does anybody know how to enable gzip compression in MVC 3? I'm using IIS7.

Google Chrome Audit's result:

  1. Enable gzip compression (4)
  2. Compressing the following resources with gzip could reduce their transfer size by about two thirds (~92.23KB):
  3. /mydomain/ could save ~1.53KB
  4. jquery-1.4.4.min.js could save ~51.35KB
  5. Cufon.js could save ~11.89KB
  6. Futura.js could save ~27.46KB

解决方案

You can configure compression through your web.config file as follows:

<system.webServer>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

You can find documentation of this configuration element at iis.net/ConfigReference. This is the equivalent of:

  1. Opening Internet Information Services (IIS Manager)
  2. Navigating through the tree-view on the left until you reach the virtual directory you wish to modify
  3. Selecting the appropriate virtual directory so that the title of the right-hand pane becomes the name of said virtual directory.
  4. Choosing "Compression" under "IIS" in the right-hand pane
  5. Ticking both options and choosing "Apply" under "Actions" on the far right.

Note: (As pointed out in the comments) You need to ensure that Http Dynamic Compression is installed otherwise setting doDynamicCompression="true" will not have any effect. The quickest way to do this is:

  1. Start > Type optionalfeatures (this is the quickest way to get to the "Turn Windows Features on or off" window)
  2. Navigate to Internet Information Services > World Wide Web Services > Performance Features in the "Windows Features" treeview
  3. Ensure "Dynamic Content Compression" is ticked
  4. Click "Ok" and wait whilst Windows installs the component

这篇关于如何在IIS7使用MVC3当我启用gzip COM pression?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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