【问题标题】:Gzip not working, server 2012, IIS 8Gzip 不工作,服务器 2012,IIS 8
【发布时间】:2016-07-28 13:51:30
【问题描述】:

在 Windows Server 2012(标准)上的 IIS 8 上激活 Gzip 的问题

  • 所以我在 windows 功能中激活了压缩
  • 我在 IIS 中选中了两个复选框 - 压缩(动态和静态)

但仍然没有可用的 Gzip。 但是,在我的 localhost 机器(只是一个 Windows 10)上,这是可行的。

我看到的是,当我通过服务器 localhost 浏览我的网站时,gzip 临时目录(C:\inetpub\temp\IIS 临时压缩文件)被填满。但奇怪的是,我在 chrome 中没有看到任何 Gzip-ped 内容。

唯一的标题(在 chrome 中)是: HTTP/1.1 304 未修改 接受范围:字节 ETag:“0a354779de8d11:0” 服务器:Microsoft-IIS/8.0 X-Powered-By: ASP.NET 日期:格林威治标准时间 2016 年 7 月 28 日星期四 13:41:04

(甚至 ys​​low 都说没有激活 gzip)

当我删除 gzip 临时文件夹并通过“官方”网站 url 浏览到该站点时,甚至什么都没有生成。

有人知道这里发生了什么吗?

//编辑: 甚至在 web.config 中添加了这个

<httpCompression> 
  <staticTypes> 
    <add mimeType="text/*" enabled="true" /> 
    <add mimeType="message/*" enabled="true" /> 
    <add mimeType="application/javascript" enabled="true" /> 
    <add mimeType="application/x-javascript" enabled="true" /> 
    <add mimeType="image/jpeg" enabled="true" /> 
    <add mimeType="*/*" enabled="false" /> 
  </staticTypes> 
  <dynamicTypes> 
    <add mimeType="text/*" enabled="true" /> 
    <add mimeType="message/*" enabled="true" /> 
    <add mimeType="application/javascript" enabled="true" /> 
    <add mimeType="application/x-javascript" enabled="true" /> 
    <add mimeType="image/jpeg" enabled="true" /> 
    <add mimeType="*/*" enabled="false" /> 
  </dynamicTypes> 
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" /> 
</httpCompression>

【问题讨论】:

    标签: iis server compression gzip iis-8


    【解决方案1】:

    以下是我解决此问题的方法:

    我在这里使用 PowerShell,但您也可以使用 GUI 或其他工具:

    确保您已安装失败的请求跟踪模块:

    Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing
    

    为您的站点启用跟踪(更改名称):

    Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='Default Web Site']/traceFailedRequestsLogging" -name "enabled" -value "True"
    

    设置跟踪:

    Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/tracing/traceFailedRequests" -name "." -value @{path='*.html'}
    Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*.html']/traceAreas" -name "." -value @{provider='WWW Server';areas='Compression';verbosity='Verbose'}
    Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*.html']/failureDefinitions" -name "statusCodes" -value "200,304"
    

    你最终会在你的 web.config 中得到类似的东西:

    <system.webServer>
        <tracing>
            <traceFailedRequests>
                <add path="*.html">
                    <traceAreas>
                        <add provider="WWW Server" areas="Compression" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions statusCodes="200,304" />
                </add>
            </traceFailedRequests>
        </tracing>
    </system.webServer>
    

    我将其限制为 http 状态为 200 或 304 的 html 文件,我们只对 Compression 感兴趣。你可能想改变它。

    现在您可以点击您的网站几次,然后查看

    C:\inetpub\logs\FailedReqLogFiles\W3SVCx
    

    对于某些文件,请将它们复制到您的工作站,因为在服务器上打开它们很痛苦。

    打开 XML 文件并单击 Request Details 选项卡,现在搜索 Compression 您应该会看到有关压缩过程的详细信息或请求未压缩的原因,例如 NOT_FREQUENTLY_HITTOO SMALL

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多