How to enable gzip compression for nginx on Plesk server

Follow

Comments

7 comments

  • Avatar
    Markus Wernecke

    Thanks a lot! Great 'n' easy tutorial.

  • Avatar
    adrianTNT

    Isn't text/html most important ? It is missing from the code.

  • Avatar
    Ekaterina Babenko

    @adrianTNT

    Hello Adrian! According to nginx official documentation, for the option gzip_types the mime-type text/html type is always compressed by default, so there is no need to specify it explicitly.
    You can check right here:
    https://nginx.org/en/docs/http/ngx_http_gzip_module.html

  • Avatar
    Lenor

    Is there any disadvantages to enable gzip globally? We often have reqests if we can enable gzip - there i want to insert this globally. 

    But will this harm any Websites in whatever way? Or is failproved ?

  • Avatar
    Ivan Postnikov

    @Lenor,

    When compressing is enabled, additional server RAM & CPU resources are utilized to compress websites content on the fly. If there are many websites on the server, the load may increase dramatically.

  • Avatar
    Lenor

    @Ivan uff. We have 300 Websites on a Server. Theres 64GB RAM. 

    Any example how i can determine if this will work or not? 

  • Avatar
    Robert Asilbekov

    @Lenor  If you mean how enabling gzip compression affect server performance - the only way is to monitor the server performance. Establish some performance baseline before enabling and see how the baseline will be changed after enabling gzip. 

     

    If you want to check whether gzip compression works you may use curl command. When gzip enabled you will see in the output 'Content-Encoding: gzip'. You can check individual files instead of pages to ensure they have been gzipped as well.

     #  curl -s -H "Accept-Encoding: gzip" -I http://domain.tld | grep Content-Encoding
    Content-Encoding: gzip

Please sign in to leave a comment.

Have more questions? Submit a request