How To Improve Django Performance

2013-08-02 08:01 Posted by: Anthony Zhan in , Go to Comment

Django help you build your website rapidly with least code duplication. Then, after you finish the developing work for your site, next thing you should consider is how to optimize it to serve more user. This article talk about the main areas to improve django performance.

Enable Cache

Cache is important for every site no matter what framework used. The lucky thing is django provide a quite simple way to enable cache. Although Django supports many cache backends, I highly recommended your choose memcached which has proved to be a high-performance distributed memory object caching system. Don't be afraid of the word "distributed", memcached is extremely simple for setup and deploy consider other distributed system. Check more information at Django’s cache framework.

Merge & Minify Media

Put different js and css in splitted files makes the code more readable, while, it may also cause too many request to the server. So you'd better merge and minity them on the product environment. Django itseft has no tools for you to do this, you'll need a 3rd party app, called django-compress. It provides an automated system for compressing CSS and JavaScript files. There is also a DEBUG mode in django-compress, which means you can still debug and edit your source files while coding, and when deploying to production, the compressed files will be automatically generated.

Enable GZip Module

Enable gzip can speed up pageload. It's said that gzip can reduce the content size by 70% ~ 80%. Of course, enable gzip take a little extra CPU and memory cost, so you'll consider which is more important. However in most cases, enable gzip is a better choice. To enable gzip you can use apache mod_deflate module in your Django hosting environment, or, simple add "django.middleware.gzip.GZipMiddleware" into your MIDDLEWARE_CLASSES in

Use separate domains for static and media files

Create subdomains for static files media files. Do not forget add their url and path to (STATIC_URL, STATIC_ROOT, MEDIA_URL, MEDIA_ROOT).

Code Level Optimization

An effective code make more senses than the aboving ways. However, how to write effective codes is not include in this article. Your can find some tips at Database access optimization.

Tagged with:

Related Articles

Week 2017/10/30 Top 5 Web Hosting Industry News
This week, there were many events happening in the web hosting industry, and to help you learn more about the industry, we carefully pick our top 5 news in the industry here.
Bisend Reseller Hosting Review
Based in Hong Kong, China and Chicago, U.S., Bisend ( is new face in the web hosting industry but with great energy.
Week 2017/9/4 Top 5 Web Hosting Industry News
There were many exciting news and events happening in the industry this week, and here we conclude the top 5 for you.
Huawei Teams up with Microsoft to Create ‘Win-Win’ Cloud Growth
Huawei discloses its MoU says it will drive its cloud growth with Microsoft, and the two together develop cloud app ecosystem with more Microsoft apps. The two sides both want to accelerate digital transformation in enterprises through it.
Week 2017/8/28 Top 5 Hosting Industry News
There were many exciting news and events happening in the industry this week, and here we conclude the top 5 for you.
Be the first to comment!
About the author
Views: 241504
Articles: 92

Author's Hot Articles


Hot Posts

Service Recommendation

Cloud Hosting
Cloud hosting is the fastest growing hosting solutions in the industry. »
Cloud Storage
Best Cloud Storage are named based on customer and expert reviews. »
The most popular SSL certificate providers in the industry are here. »
China Web Hosting
Find out a comprehensive evaluation to the host service provider in China. »