During Speed testing of your website or web application using LoadFocus (https://loadfocus.com/website-speed-testing) on the Advice section you might get the tip that you need to enable compression like in the image below:
Are Your APIs as Reliable as You Think?
Don’t let hidden issues disrupt your service. With LoadFocus’s advanced API Monitoring, catch problems before they impact your users. Ensure flawless performance and avoid costly outages—monitor, test, and optimize your APIs effortlessly.
Compressing responses often significantly reduces the size of transmitted data. Because the compression happens at runtime this can add a big processing overhead which can affect the performance in a negative way.
Think your website can handle a traffic spike?
Fair enough, but why leave it to chance? Uncover your website’s true limits with LoadFocus’s cloud-based Load Testing for Web Apps, Websites, and APIs. Avoid the risk of costly downtimes and missed opportunities—find out before your users do!
Nginx if configured correctly compresses the responses before sending them to the clients and does not double compress the responses which have been already compressed.
In the next tutorial we will show how you can enable compression in case you are using Nginx to serve your files.
1. First locate the Nginx configuration file – nginx.conf 2. Once you located the file open the file and make sure that inside the configuration you can find the following flags:
LoadFocus is an all-in-one Cloud Testing Platform for Websites and APIs for Load Testing, Apache JMeter Load Testing, Page Speed Monitoring and API Monitoring!
gzip_disable “msie6” – disable compression for IE6 as IE6 doesn’t always read and cache gzipped content properly and you end up with mangled code
gzip_vary on – enables / disables inserting the “Vary: Accept-Encoding” response header field if the directives gzip, gzip_static, or gunzip are active
gzip_proxied any – enables or disables gzipping of responses for proxied requests depending on the request and response; the fact that the request is proxied is determined by the presence of the “Via” request header field
gzip_comp_level 5 – sets a gzip compression level of a response; the values that are acceptable are between 1 and 9; 5 is a good compromise between size and cpu usage
gzip_buffers 16 8k – sets the number and size of buffers used to compress a response; by default, the buffer size is equal to either 4K or 8K, depending on a platform
gzip_http_version 1.1 – sets the minimum HTTP version of a request required to compress a response
gzip_min_length 1000 – specifies the minimum length of the response to compress; the default is 20 bytes; don’t compress anything that’s already small and unlikely to shrink
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript – by default gzip compression is applied only to responses with MIME type text/html; to enable it for other types of MIME we need to add them to this flag
4. The flags that are most important are the “gzip on” and “gzip_types”
5. The directives/flags that configure compression can be included in the http context or in a server or location configuration block
6. Restart Nginx by doing sudo service nginx restart
7. After you’ve finishes to enable compression on your server run the LoadFocus speed test again. This time the tip regarding to Enable compression should say that everything is fine.
LoadFocus.com is a Cloud Testing Platform used for Load and Performance Testing for Websites and APIs and Website Speed Testing with Analytics.