cURL: Check Nginx/Apache Compression (br, gzip, deflate) is Working - Comment Page: 1
This is a quick method to check with using cURL that Nginx/Apache (or any other web server) compression with Nginx ngx_http_gzip_module (gzip), Nginx google/ngx_brotli (br), Apache mod_brotli (br), Apache mod_gzip (gzip) and Apache mod_deflate (deflate) is working. Only the remote server headers are needed.
Check that the Nginx/Apache Compression is Working
[inttf_post_ad1]
Get headers
curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://www.if-not-true-then-false.com
-s option silent, disable progress bar.
-I option which will make just HEAD request to server and get headers.
-H option add header for accept content-encoding br, gzip and deflate.
Check headers
###...
using GET from libwww-perl accomplishes the same:
$ GET -Used -H ‘Accept-Encoding: gzip,deflate’ http://www.if-not-true-then-false.com
GET http://www.if-not-true-then-false.com
Accept-Encoding: gzip,deflate
User-Agent: lwp-request/5.827 libwww-perl/5.833
200 OK
Connection: close
Date: Fri, 21 Jun 2013 14:08:58 GMT
Server: cloudflare-nginx
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
CF-RAY: 821461943d802fe
Client-Date: Fri, 21 Jun 2013 14:08:58 GMT
Client-Peer: 108.162.205.105:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Set-Cookie: __cfduid=df093f70060aed36cb454e9167973aa341371823737; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.if-not-true-then-false.com
X-CF-Powered-By: WP 1.3.9
X-Pingback: http://www.if-not-true-then-false.com/xmlrpc.php
X-Powered-By: PHP/5.4.16
PS: your WP version seems a bit old, but I do not know anything about WP, just checked their site and as of 21 june 2013, the latest advertised is 3.5.1 and there is quite a big fat warning about the rest not being safe to use.
Hi oxtan,
Yes this is one method to get same info, thanks for sharing.
Actually this WP 1.3.9 have nothing to do with WordPress version…it just CloudFlare plugin version. :)
With the generic cUrl, you have to write the string double quoted.
“www.mywebsite.com”
Sorry!
Thanks for that!!
This works – most of the time. But the -I option does a HEAD request. Even though gzip is enabled on a server, it may not compress the HEAD request. I found that this solution is more reliable:
curl -sD – -o /dev/null http://example.com
https://stackoverflow.com/a/26644485/960857
Hi Chris,
Thanks for your input, but actually your method is not even working? I can’t see content-encoding at all if I run:
This guide command output:
I updated guide added brotli + curl silent. But I really can’t see any situation where HEAD request with Accept-Encoding does not work? HEAD response shouldn’t be compressed and your web server doesn’t work right if it doesn’t tell to client (browser) what encoding it uses.
If you send plain HEAD request without Accept-Encoding, then server usually omit content-encoding, like stackoverflow discussion says, but actually original question is about the request headers and this guide CURL command send request header
-H 'Accept-Encoding: br,gzip,deflate'
and check response headersContent-Encoding:
so this is totally different thing.If you think situation where browser sends request with ‘Accept-Encoding: br,gzip,deflate’ and your web server response is gzipped, but there is no Content-Encoding: header your browser shows gzipped response as plain text. So if you really can’t see content-encoding header on HEAD response when you use accept-encoding request header, then you really should check your web server configuration and fix it!!