设置django 设置响应头Content-Length:
http协议中content-length 以及chunked编码分析http://blog.csdn.net/yankai0219/article/details/8269922
在djangobook中找到了如下内容
条件化的GET中间件
中间件类: django.middleware.http.ConditionalGetMiddleware .
这个中间件对条件化 GET 操作提供支持。如果response头中包括 Last-Modified 或 ETag 域,并且request头中包含 If-None-Match 或 If-Modified-Since 域,且两者一致,则该response将被response 304(Not modified)取代。对 ETag 的支持依赖于 USE_ETAGS 配置及事先在response头中设置 ETag 域。稍前所讨论的通用中间件可用于设置response中的 ETag 域。
此外,它也将删除处理 HEAD request时所生成的response中的任何内容,并在所有request的response头中设置 Date 和 Content-Length 域。
原文地址http://py3k.cn/chapter15/
在settings.py中添加此中间件,返回结果如下