How can I tell if my server is serving GZipped con

2019-01-12 17:27发布

I have a webapp on a NGinx server. I set gzip on in the conf file and now I'm trying to see if it works. YSlow says it's not, but 5 out of 6 websites that do the test say it is. How can I get a definite answer on this and why is there a difference in the results?

8条回答
淡お忘
2楼-- · 2019-01-12 17:44

Another useful tool: http://gzipwtf.com

It's the only tool I've seen that will parse your page and find all directly referenced resources (css, js files etc.), and tell you if each of them are gzipped, instead of just telling you if the index page is gzipped.

Also provides other useful statistics (time to download resource, speed, etc.)

查看更多
疯言疯语
3楼-- · 2019-01-12 17:48

None of the online tools above could test my URL which was an XML file, however this one does the job right:

http://www.feedthebot.com/tools/gzip/

gzip test sample

查看更多
我只想做你的唯一
4楼-- · 2019-01-12 17:52

You could quickly use a web service like: http://www.whatsmyip.org/http-compression-test/

Google Chrome's "Audits" tool in the developer tools comes in handy as well.

查看更多
劫难
5楼-- · 2019-01-12 17:53

It looks like one possible answer is, unsurprisingly, curl:

$ curl http://example.com/ --silent --write-out "%{size_download}\n" --output /dev/null
31032
$ curl http://example.com/ --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null
2553

In the second case the client tells the server that it supports content encoding and you can see that the response was indeed shorter, compressed.

查看更多
SAY GOODBYE
6楼-- · 2019-01-12 17:54

In new version of chrome, Developer tools > network, you can right click on Column name, and select content-encoding option and add that column (black box in image).

and if you want to see the size of that gzip content, as @Outfast Source - than you can click on icon which is next to View (displayed as Green box in image).

so you can see which content is gzip enabled.

enter image description here

查看更多
在下西门庆
7楼-- · 2019-01-12 18:00

I wrote this script based on the zoul's answer:

#!/bin/bash

URL=$1
PLAIN="$(curl $URL --silent --write-out "%{size_download}\n" --output /dev/null)"
GZIPPED="$(curl $URL --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null)"

if test $PLAIN -gt $GZIPPED
then echo "supported"
else echo "unsupported"
fi

example:

$ ./script.sh https://example.com/
查看更多
登录 后发表回答