==How to enable gzip compression in nginx for static files and speed up your site == to nginx configuration file /etc/nginx/nginx.conf add in "http" directive these lines: gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss application/javascript text/javascript; Save file and restart the nginx: /etc/init.d/nginx restart After that all the css and javasripts files will be compressed on the server side and your sites will work faster.
Thank you for the great tutorial, this could be very helpful, I would add an advice of using cloudflare to make the files even more compressed, or by minifiying your files.
this is iam use for my site: gzip on; gzip_comp_level 6; gzip_min_length 512; gzip_buffers 8 64k; gzip_types application/json application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml; gzip_proxied any; gzip_vary on; PHP: sorry for OOT, anyone have using brotli?
You can the below snippet to the .conf file in order to enable Nginx gzip. 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 application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/plain text/xml; hope this helps