I am looking to enable text compression in Django. The performance docs reference GZip Middleware as the current solution for text compression. However, it comes with a stern warning:
GZipMiddleware
Compresses responses for all modern browsers, saving bandwidth and transfer time. Note that GZipMiddleware is currently considered a security risk, and is vulnerable to attacks that nullify the protection provided by TLS/SSL. See the warning in GZipMiddleware for more information.
A couple of questions:
- Are there any text compression alternatives I can use with Django that are not subject to security risks?
- If I use CSRF tokens when using
POST
and I have CSRF Middleware enabled am I safe?
Again, via the docs:
Changed in Django 1.10: In older versions, Django’s CSRF protection mechanism was vulnerable to BREACH attacks when compression was used. This is no longer the case, but you should still take care not to compromise your own secrets this way.