+2 votes
in Web & Google by (11.1k points)

I have the following parameters in my nginx.conf file to compress the static contents, however, when I test my Wordpress page on google pagespeed, it complains about 2 javascript files that are not compressed. What changes I need to make in the nginx.conf file to fix the error.

gzip on;

gzip_vary on;

gzip_disable "MSIE [1-6]\.";

gzip_proxied any;

gzip_http_version 1.1;

gzip_min_length 1000;

gzip_comp_level 2;

gzip_buffers 16 8k;

gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml application/xhtml+xml image/svg+xml image/x-icon;

1 Answer

0 votes
by (15.8k points)

Everything in your configuration file looks okay. Do you know the size of the javascript files that come in pagespeed's error report? The possibilities are: 1. those files are smaller than 1k or 2. bigger than 8k. Make the following changes in your nginx.conf file and see if it works.

    gzip on;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    gzip_proxied any;
    gzip_http_version 1.1;
    gzip_min_length 25;
    gzip_comp_level 2;
    gzip_buffers 16 32k;
    gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml application/xhtml+xml image/svg+xml image/x-icon;
 

gzip_min_length 1000: Minimum file size that should be compressed. If your file size is less than 1k, nginx will ignore your file.

gzip_buffers 16 8k: Sets the number and size of buffers used to compress a response. If the buffer size needed for your file is more than 8k, it might not work.

...