Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #5047: patch_cache_control now respects existing max-age settin…

…gs. Thanks, permon.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2dd882885b8d72941a706048c59fec3f84d7377f 1 parent 632a424
Jacob Kaplan-Moss authored
1  AUTHORS
@@ -234,6 +234,7 @@ answer newbie questions, and generally made Django that much better:
234 234
     Jay Parlar <parlar@gmail.com>
235 235
     pavithran s <pavithran.s@gmail.com>
236 236
     Barry Pederson <bp@barryp.org>
  237
+    permonik@mesias.brnonet.cz
237 238
     petr.marhoun@gmail.com
238 239
     pgross@thoughtworks.com
239 240
     phaedo <http://phaedo.cx/>
7  django/utils/cache.py
@@ -57,6 +57,13 @@ def dictvalue(t):
57 57
         cc = dict([dictitem(el) for el in cc])
58 58
     else:
59 59
         cc = {}
  60
+
  61
+    # If there's already a max-age header but we're being asked to set a new
  62
+    # max-age, use the minumum of the two ages. In practice this happens when
  63
+    # a decorator and a piece of middleware both operate on a given view.
  64
+    if 'max-age' in cc and 'max_age' in kwargs:
  65
+        kwargs['max_age'] = min(cc['max-age'], kwargs['max_age'])
  66
+
60 67
     for (k,v) in kwargs.items():
61 68
         cc[k.replace('_', '-')] = v
62 69
     cc = ', '.join([dictvalue(el) for el in cc.items()])

0 notes on commit 2dd8828

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