Gzip not working, server 2012, IIS 8

梦想的初衷 提交于 2019-12-01 12:27:05

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!