diff options
| author | shanghui <shangdahao@gmail.com> | 2018-02-06 13:44:53 +0800 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-06 09:42:05 -0500 |
| commit | d968788b57f41b7def88046d1178fd2932a32a4e (patch) | |
| tree | 4deb03cc07e4525db103e8b26f6cc5726acf18da /django/middleware | |
| parent | 272f685794de0b8dead220ee57b30e65c9aa097c (diff) | |
Fixed #28833 -- Prevented CacheMiddleware from caching responses with "Cache-Control: private".
Diffstat (limited to 'django/middleware')
| -rw-r--r-- | django/middleware/cache.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/middleware/cache.py b/django/middleware/cache.py index 8af0c9db7c..6b320f1db5 100644 --- a/django/middleware/cache.py +++ b/django/middleware/cache.py @@ -85,6 +85,10 @@ class UpdateCacheMiddleware(MiddlewareMixin): if not request.COOKIES and response.cookies and has_vary_header(response, 'Cookie'): return response + # Don't cache a response with 'Cache-Control: private' + if 'private' in response.get('Cache-Control', ()): + return response + # Try to get the timeout from the "max-age" section of the "Cache- # Control" header before reverting to using the default cache_timeout # length. |
