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

4

9

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?

Querist answered 13/7, 2009 at 19:36 Comment(0)
N
6

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.

Nivernais answered 13/7, 2009 at 19:43 Comment(0)
M
2

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.

Masto answered 13/7, 2009 at 19:42 Comment(0)
F
2

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.

Fruitful answered 20/1, 2015 at 14:17 Comment(0)
V
1

I would definitely go with mod_deflate, on the assumption that you have static css and js files which apache is serving directly and can also be compressed.

Vicky answered 25/9, 2009 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.