Compress the server response with Nginx

Maybe you aware with apache “mod_gzip and mod deflate”

Compress the server response with Nginx

Web page compression is not a new technology, but it has recently gained higher recognition in the minds of IT administrators and managers because of the rapid ROI it generates. Compression extensions exist for most of the major Web server platforms

For Apache Normally use following syntax:

mod_gzip_item_exclude file \.js$
mod_gzip_item_exclude mime ^text/css$

mod_gzip_item_include file \.html$
mod_gzip_item_include file \.shtml$
mod_gzip_item_include file \.php$
mod_gzip_item_include mime ^text/html$

mod_gzip_item_include file \.txt$
mod_gzip_item_include mime ^text/plain$

mod_gzip_item_include file \.css$
mod_gzip_item_include mime ^text/css$

We used gzip and compressing files technology with various browers. You need following browser support for this.

  • Accept-encoding: gzip
  • Accept-encoding: gzip, deflate

For Nginx i used following code in Nginx.conf file:

# Compression of response time
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 9;
gzip_http_version 1.0;
gzip_min_length 0;
gzip_types text/plain text/html text/css image/x-icon image/png image/jpg image/jpeg text/js text/php;
gzip_vary on;

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “Compress the server response with Nginx”

Leave a Reply

Your email address will not be published.