I have hosted my website on Amazon Elastic BeanStalk. It uses nginx as proxy server and has gzip compression enabled. But when I run PageInsights on the site, it reports that many of my static content files need to be gzipped. Why is PageSpeed Insights not recognizing the compression? Is there something extra that needs to be done?
Double click on the file and select headers. Under 'Response headers' you are looking for the 'Connection-Encoding' field, it will say gzip if it is enabled.
Gzip, the most popular compression method, is used by web servers and browsers to seamlessly compress and decompress content as it's transmitted over the Internet. Used mostly on code and text files, gzip can reduce the size of JavaScript, CSS, and HTML files by up to 90%.
Gzip on Windows Servers (IIS Manager)Open up IIS Manager. Click on the site you want to enable compression for. Click on Compression (under IIS) Now Enable static compression and you are done!
I think I actully found the answer
By enabling gzip compression on nginx, you enable it only for text/html (that is nginx default http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip_types)
In order to enable it for other types, you have to do it explicitly. In case of beanstalk, create the following file in your project
.ebextensions/gzip.config
and put the code there (make sure you keep the indentation, it is important):
files:
/etc/nginx/conf.d/gzip.conf:
content: |
gzip_types application/json;
As you can see, in my case I needed to gzip json files, you are probably having problems with Pagespeed complaining about css and js files, right? As the link above suggests you can use a * wildcard to compress everything, but if not, just list the mime types you need in the config, deploy it, and check PageSpeed Insights again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With