GZip compression allows the server to compress data before it is sent (on the fly) and the upon arrival of the data on client side, the browser does the unzipping/decompression of the data and shows it to the user. Enabling gzip compression can help you save about 50% plus bandwidth, thus not only making your site more responsive, but also saving huge amount of cost. Here's how you enable gzip compression in Django:
Open your settings.py file and find the MIDDLEWARE_CLASSES tuple. Add the following at the top:
Open your settings.py file and find the MIDDLEWARE_CLASSES tuple. Add the following at the top:
MIDDLEWARE_CLASSES = ( 'django.middleware.gzip.GZipMiddleware', # ... )
And, that's it! You can also enable gzip compression from your Apache, Ngingx and other servers too, look up their documentation.
No comments:
Post a Comment