Let’s start with things that do not really concern Django. With Gzip + Nginx.
Gzip
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 https://lingomost.com/ --silent --write-out "%{size_download}\n" --output /dev/null
>> 38849
Response length without encoding is 38849.
curl https://lingomost.com/ --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
.