Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mod_deflate vs Django GZipMiddleware, which one to use for deployment?

We're deploying Django apps with Apache 2.2 + mod_wsgi. Should we enable mod_deflate in Apache or use Django's GZipMiddleware? Which option performs better?

like image 242
Imran Avatar asked Jul 13 '09 19:07

Imran


3 Answers

You should probably test to know for sure, but if I were to guess, mod_deflate would be better for requests that totally bypass Django completely (like zipped up static resources that should be deployed separately i.e. media).

For things that are already generated by Django responses, it's probably a toss-up -- in either case it would be native code doing the zipping.

like image 117
Lou Franco Avatar answered Nov 01 '22 10:11

Lou Franco


It depends. If you enable it in Apache, then it will also be used for static content (e.g. CSS, Javascript, images); but some static content (like JPG, GIF, SWF) is pretty well compressed anyway.

like image 43
Vinay Sajip Avatar answered Nov 01 '22 09:11

Vinay Sajip


mod_deflate is a better choice because it allows you to choose which content types are compressed (defaults to html, css and js).

GZipMiddleware is very naive and will try to compress anything and just check if the result is smaller than the original response. If you're serving images that way you will take the performance hit for each request with 0 benefit.

like image 2
Philippe Raoult Avatar answered Nov 01 '22 11:11

Philippe Raoult