有关Django性能优化总结
- 21 Jan 2009
- Posted in django
- 内存、内存,还是加内存
- 使用单独的静态文件服务器
- 关闭KeepAlive(如果服务器不提供静态文件服务,如:大文件下载)
- 使用memcached
- 使用select_related()加载关联表数据
- 使用values()过滤不必要的字段查询
- 使用模板cache
- 加载编译的模板 例如下面代码并非直接用 render_to_response
from django.template import loader
from django.http import HttpResponse
#loads and compiles the template
myview_template = loader.get_template('path/to/template.html')
def myview(request):
# do sth¡
return HttpResponse(myview_template.render( context ))