Gzip不工作,服务器2012,IIS 8 [英] Gzip not working, server 2012, IIS 8

查看:233
本文介绍了Gzip不工作,服务器2012,IIS 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows服务器2012(标准)上在IIS 8上激活Gzip时出现的问题




  • 所以我激活了Windows中的压缩功能

  • 我在IIS中选中了两个复选框 - 压缩(动态和静态)



可用。
然而,在我的本地机器(只是一个Windows 10)这工作。



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



唯一的标题(在chrome)是:
HTTP / 1.1 304未修改
Accept-Ranges:bytes
ETag:0a354779de8d11:0
服务器:Microsoft-IIS / 8.0
X-Powered- By:ASP.NET
日期: ,2016年7月28日13:41:04 GMT



(即使yslow表示没有gzip已启动)



当我删除gzip临时文件夹,并通过官方网站的URL浏览到网站,甚至没有生成任何东西。



任何人都有任何想法在这里?



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

 < httpCompression> 
< staticTypes>
< add mimeType =text / *enabled =true/>
< add mimeType =message / *enabled =true/>
< add mimeType =application / javascriptenabled =true/>
< add mimeType =application / x-javascriptenabled =true/>
< add mimeType =image / jpegenabled =true/>
< add mimeType =* / *enabled =false/>
< / staticTypes>
< dynamicTypes>
< add mimeType =text / *enabled =true/>
< add mimeType =message / *enabled =true/>
< add mimeType =application / javascriptenabled =true/>
< add mimeType =application / x-javascriptenabled =true/>
< add mimeType =image / jpegenabled =true/>
< add mimeType =* / *enabled =false/>
< / dynamicTypes>
< scheme name =gzipdll =%Windir%\system32\inetsrv\gzip.dlldynamicCompressionLevel =4/>
< / httpCompression>


解决方案

以下是我如何解决此问题:



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



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

  Enable-WindowsOptionalFeature -Online-FeatureName IIS-HttpTracing 



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

 code> Set-WebConfigurationProperty -pspath'MACHINE / WEBROOT / APPHOST'-filtersystem.applicationHost / sites / site [@ name ='Default Web Site'] / traceFailedRequestsLogging-nameenabled-valueTrue 

设置跟踪:

  Add-WebConfigurationProperty -pspath'MACHINE / WEBROOT / APPHOST /默认网站'-filtersystem.webServer / tracing / traceFailedRequests-name。 -value @ {path ='*。html'} 
添加WebConfigurationProperty -ps路径'MACHINE / WEBROOT / APPHOST /默认网站'过滤器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'-filtersystem.webServer / tracing / traceFailedRequests / add [@path ='*。html'] / failureDefinitions-namestatusCodes-value200,304

你最终会在你的web.config中得到这样的结果:

 < system.webServer& 
< tracing>
< traceFailedRequests>
< add path =*。html>
< traceAreas>
< add provider =WWW Serverareas =Compressionverbosity =Verbose/>
< / traceAreas>
< failureDefinitions statusCodes =200,304/>
< / add>
< / traceFailedRequests>
< / tracing>
< /system.webServer>

我将它限制为http状态为200或304的html文件, code> Compression 。



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

  C:\inetpub\logs\FailedReqLogFiles\W3SVCx 

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



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


Problems with activating Gzip on IIS 8 on a windows server 2012 (standard)

  • So i activated the compressions in the windows features
  • I checked both checkboxes in IIS - compression (dynamic and static)

But still no Gzip available. However, on my localhost machine (just a windows 10) this works.

What i do see, is that the gzip temp directory (C:\inetpub\temp\IIS Temporary Compressed Files) is getting filled up when i browse my site via the server localhost. BUT strangely enough i'm not seeing anything Gzip-ped in chrome.

The only headers (in chrome) are: HTTP/1.1 304 Not Modified Accept-Ranges: bytes ETag: "0a354779de8d11:0" Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET Date: Thu, 28 Jul 2016 13:41:04 GMT

(Even yslow is saying no gzip is activated)

When i remove the gzip temp folder, and browse to the site trough the 'official' website url, then nothing is even generated.

Does anyone has any idea what is going on here?

//edit: Even added this in the 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>

解决方案

Here's how I would troubleshoot this:

I'm using PowerShell here, but you could use the GUI or other tools as well:

Make sure you have the failed request tracing module installed:

Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpTracing

enable the tracing for your site (change the name):

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

Setup tracing:

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"

you end up with something like this in your 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>

I limited it to html files with a http status of 200 or 304 and we are only interested in Compression. You may want to change that.

Now you can hit your site a few times and then look in

C:\inetpub\logs\FailedReqLogFiles\W3SVCx

for some files, copy them to your workstation, because it's a pain to open them on the server.

Open the XML files and click on the Request Details tab, now search for Compression you should see details about the compression process or a reason why the request wasn't compress, like NOT_FREQUENTLY_HIT or TOO SMALL

这篇关于Gzip不工作,服务器2012,IIS 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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