How can I tell if my server is serving GZipped content?

后端 未结 6 1946
逝去的感伤
逝去的感伤 2020-12-04 05:56

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

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 06:32

    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/
    

提交回复
热议问题