Robert
Robert

Reputation: 511

Gzip files are not being read by the Nginx server, even though gzip compression is enabled

When analyzing my site on PageSpeed Insights it suggests to enable text compression, however the files that it mentions have already been gzipped, and gzip compression is already enabled on my nginx server.

The files PageSpeed Insights said needed to be gzipped in my Angular dist package are: main.js, polyfills.js, styles.css

All of those files have been successfully gzipped via ng build --prod && gzip-all "dist/*.*", so they exist in the dist folder.

Network Tab shows gzip content encoding is enabled on the nginx server:

**Network Tab** shows gzip content encoding is enabled

Nginx.config Gzip Settings:

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

For some reason it's not reading the gzipped files.

Upvotes: 2

Views: 2849

Answers (1)

jcuypers
jcuypers

Reputation: 1794

By default it only compresses text/html. you need to uncomment other mime types you want to compress like:

gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

https://docs.nginx.com/nginx/admin-guide/web-server/compression/

Upvotes: 5

Related Questions