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 ###...

6 comments on “cURL: Check Nginx/Apache Compression (br, gzip, deflate) is Working - Comment Page: 1

    1. 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.

      Reply
      • 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. :)

        Reply
    2. With the generic cUrl, you have to write the string double quoted.
      “www.mywebsite.com”

      Reply
      • Sorry!
        Thanks for that!!

        Reply
      • 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:

        curl -sD - -o /dev/null https://www.if-not-true-then-false.com
        HTTP/2 200 
        date: Wed, 10 Oct 2018 09:47:41 GMT
        content-type: text/html; charset=UTF-8
        set-cookie: __cfduid=d7b01497c7d78807de839b6026de6904c1539164861; expires=Thu, 10-Oct-19 09:47:41 GMT; path=/; domain=.if-not-true-then-false.com; HttpOnly
        vary: Accept-Encoding
        x-powered-by: PHP/7.2.8
        link: ; rel="https://api.w.org/"
        x-cache: HIT
        x-page-speed: 1.13.35.2-0
        cache-control: max-age=0, no-cache
        expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
        server: cloudflare
        cf-ray: xxx
        

        This guide command output:

        curl -s -I -H 'Accept-Encoding: br,gzip,deflate' https://www.if-not-true-then-false.com
        HTTP/2 200 
        date: Wed, 10 Oct 2018 09:51:41 GMT
        content-type: text/html; charset=UTF-8
        set-cookie: __cfduid=d5a9ca6e020ef64a4a25fa2e09de788ea1539165101; expires=Thu, 10-Oct-19 09:51:41 GMT; path=/; domain=.if-not-true-then-false.com; HttpOnly
        vary: Accept-Encoding
        x-powered-by: PHP/7.2.8
        link: ; rel="https://api.w.org/"
        x-cache: EXPIRED
        x-page-speed: 1.13.35.2-0
        cache-control: max-age=0, no-cache
        expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
        server: cloudflare
        cf-ray: xxx
        content-encoding: br
        

        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 headers Content-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!!

        Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close