Skip to content

Commit

Permalink
Changed django.utils.cache.patch_response_headesr to move unnecessary…
Browse files Browse the repository at this point in the history
… calculation of 'expires' into the 'if' statement

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2528 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
adrianholovaty committed Mar 17, 2006
1 parent a05e05a commit 426e722
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def patch_response_headers(response, cache_timeout=None):
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
now = datetime.datetime.utcnow()
expires = now + datetime.timedelta(0, cache_timeout)
if not response.has_header('ETag'):
response['ETag'] = md5.new(response.get_content_as_string('utf8')).hexdigest()
if not response.has_header('Last-Modified'):
response['Last-Modified'] = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
if not response.has_header('Expires'):
expires = now + datetime.timedelta(0, cache_timeout)
response['Expires'] = expires.strftime('%a, %d %b %Y %H:%M:%S GMT')
patch_cache_control(response, max_age=cache_timeout)

Expand Down

0 comments on commit 426e722

Please sign in to comment.