Usually I use Apache but I’m starting to use nginx as webserver to serve both the static files and the proxied gunicorn response.
I need to do something like what I’ve done with Apache to compress the response after I received from django since I’ve noticed that in my case compressing it before using @gzip_page decorator is more detrimental to performance than doing it after.
Here an essential mysite.conf to put in /etc/nginx/conf.d.
In this way, content by Gunicorn is served to nginx and before to send it to client nginx gzip it, here with a compression level of 4 of 9. A compression between 1 and 4 is generally acceptable for any text content, avoiding to stress the CPU too much for a small compression gain.
Read also on the same topic: How to enable gzip on proxy servers on Apache
- Setting up Django with Nginx, Gunicorn, virtualenv, supervisor and PostgreSQL
- Gzip on nginx documentation