Django project optimization: Nginx + Gzip (part 1)

Let’s start with things that do not really concern Django. With Gzip + Nginx.


With Nginx, go to /etc/nginx/nginx.conf (or make a separate /etc/nginx/conf.d/*.conf) and in the body of http add:

gzip on;
gzip_disable "msie6";

Then with curl you can check whether it worked, in the example you see my website Lingomost:

curl --silent --write-out "%{size_download}\n" --output /dev/null
>> 38849

Response length without encoding is 38849.

curl --silent -H "Accept-Encoding: gzip,deflate" --write-out "%{size_download}\n" --output /dev/null
>> 7623

And with Accept-Encoding it is 7623 -> therefore the settings applied succesfully.

Or you can look at files in Chrome/Chromium -> F12 -> Network and look for Content-Encoding line in Response Headers.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.