Code

Ticket #15499: allow-cache-control-private-override.diff

File allow-cache-control-private-override.diff, 661 bytes (added by AndiDog, 3 years ago)

Simple patch

Line 
1Index: django/utils/cache.py
2===================================================================
3--- django/utils/cache.py       (revision 15646)
4+++ django/utils/cache.py       (working copy)
5@@ -67,6 +67,12 @@
6     if 'max-age' in cc and 'max_age' in kwargs:
7         kwargs['max_age'] = min(cc['max-age'], kwargs['max_age'])
8 
9+    # Allow overriding private caching and vice versa
10+    if 'private' in cc and 'public' in kwargs:
11+        del cc['private']
12+    elif 'public' in cc and 'private' in kwargs:
13+        del cc['public']
14+
15     for (k, v) in kwargs.items():
16         cc[k.replace('_', '-')] = v
17     cc = ', '.join([dictvalue(el) for el in cc.items()])