如何在IIS 7.5中启用GZIP压缩 [英] How to enable GZIP compression in IIS 7.5

查看:144
本文介绍了如何在IIS 7.5中启用GZIP压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用GZIP压缩我的文件。你可以回答用GZIP压缩文件的web.config代码。

I want to compress my files using GZIP. Can you answer the web.config code for compressing files with GZIP.

在上传我的web.config文件后,还有什么需要做的事吗?

Is there anything more that I have to do after uploading my web.config file?

推荐答案

有两种方法:


  1. 静态压缩

  2. 动态压缩

IIS 7.x中的压缩在空间中配置有两个.config文件元素。
元素可以在IIS / ASP.NET配置管道中的任何地方设置,从ApplicationHost.config到本地web.config文件。
以下是来自ApplicationHost.config(在%windir%\System32\inetsrv\config forlder中)的默认设置在IIS 7.5上的几个小调整(添加json输出和启用动态压缩):

Compression in IIS 7.x is configured with two .config file elements in the space. The elements can be set anywhere in the IIS/ASP.NET configuration pipeline all the way from ApplicationHost.config down to the local web.config file. The following is from the the default setting in ApplicationHost.config (in the %windir%\System32\inetsrv\config forlder) on IIS 7.5 with a couple of small adjustments (added json output and enabled dynamic compression):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
      <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>

    <urlCompression doStaticCompression="true" doDynamicCompression="true" />

  </system.webServer>
</configuration>

请参阅 http://weblog.west-wind.com/posts/2011/May/05/Builtin-GZipDeflate-Compression-on-IIS-7x 了解更多详情

这篇关于如何在IIS 7.5中启用GZIP压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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