Tag: gzip

  • gzip

    Enable Gzip in Amazon Linux
    How to enable gzip on Plesk Nginx

    To check if a web site have gzip enabled, run

    curl -I -H 'Accept-Encoding: gzip,deflate' https://YOUR_DOMAIN.EXTN
    

    When you have no GZIP enabled, you will see error as follows

    boby@hon-pc-01:~$ curl -I -H 'Accept-Encoding: gzip,deflate' https://serverok.in
    curl: (7) Failed to connect to serverok.in port 443: Connection refused
    boby@hon-pc-01:~$ 
    

    With gzip enabled, you see something like following

    boby@hon-pc-01:~$ curl -I -H 'Accept-Encoding: gzip,deflate' https://serverok.in
    HTTP/1.1 200 OK
    Server: nginx/1.10.3 (Ubuntu)
    Date: Sat, 23 Dec 2017 16:53:49 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Link: ; rel="https://api.w.org/"
    Link: ; rel=shortlink
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    Content-Encoding: gzip
    
    boby@hon-pc-01:~$ 
    

    To enable gzip on nginx web server, i added following to server block

    gzip          on;
    gzip_comp_level     5;
    gzip_min_length     256;
    gzip_types
        application/atom+xml
        application/javascript
        application/json
        application/rss+xml
        application/vnd.ms-fontobject
        application/x-font-ttf
        application/x-font-opentype
        application/x-font-truetype
        application/x-javascript
        application/x-web-app-manifest+json
        application/xhtml+xml
        application/xml
        font/eot
        font/opentype
        font/otf
        image/svg+xml
        image/x-icon
        image/vnd.microsoft.icon
        text/css
        text/plain
        text/javascript
        text/x-component;
    gzip_disable  "MSIE [1-6]\.(?!.*SV1)";