Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Changed ETag computation to first check if an ETag header already exi…

…sts in the


git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent bccb889 commit 9b397ee50d3ba3c29c754ad54b9181b4f300ea6f @malcolmt malcolmt committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 django/middleware/
8 django/middleware/
@@ -11,7 +11,8 @@ class CommonMiddleware(object):
- Forbids access to User-Agents in settings.DISALLOWED_USER_AGENTS
- URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings,
- this middleware appends missing slashes and/or prepends missing "www."s.
+ this middleware appends missing slashes and/or prepends missing
+ "www."s.
- ETags: If the USE_ETAGS setting is set, ETags will be calculated from
the entire page content and Not Modified responses will be returned
@@ -74,7 +75,10 @@ def process_response(self, request, response):
# Use ETags, if requested.
if settings.USE_ETAGS:
- etag =
+ if response.has_header('ETag'):
+ etag = response['ETag']
+ else:
+ etag =
if response.status_code >= 200 and response.status_code < 300 and request.META.get('HTTP_IF_NONE_MATCH') == etag:
response = http.HttpResponseNotModified()

0 comments on commit 9b397ee

Please sign in to comment.
Something went wrong with that request. Please try again.