summaryrefslogtreecommitdiff
path: root/django/utils/cache.py
diff options
context:
space:
mode:
authorDenis Cornehl <syphar@fastmail.fm>2016-04-03 12:15:10 +0200
committerTim Graham <timograham@gmail.com>2016-10-10 14:55:59 -0400
commita840710e1e38bc9e55412bb36eca92eff94ebd2c (patch)
treeb6ab8b8456eea42645949cb46114fbab50aae0fa /django/utils/cache.py
parent46a3d7604e7fecde8df02ec363200ec5e0ce894e (diff)
downloaddjango-a840710e1e38bc9e55412bb36eca92eff94ebd2c.tar.gz
Fixed #26447 -- Deprecated settings.USE_ETAGS in favor of ConditionalGetMiddleware.
Diffstat (limited to 'django/utils/cache.py')
-rw-r--r--django/utils/cache.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index e74bfbea5d..8d0ce4dac5 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -22,10 +22,12 @@ import hashlib
import logging
import re
import time
+import warnings
from django.conf import settings
from django.core.cache import caches
from django.http import HttpResponse, HttpResponseNotModified
+from django.utils.deprecation import RemovedInDjango21Warning
from django.utils.encoding import force_bytes, force_text, iri_to_uri
from django.utils.http import (
http_date, parse_etags, parse_http_date_safe, quote_etag,
@@ -242,6 +244,13 @@ def patch_response_headers(response, cache_timeout=None):
if cache_timeout < 0:
cache_timeout = 0 # Can't have max-age negative
if settings.USE_ETAGS and not response.has_header('ETag'):
+ warnings.warn(
+ "The USE_ETAGS setting is deprecated in favor of "
+ "ConditionalGetMiddleware which sets the ETag regardless of the "
+ "setting. patch_response_headers() won't do ETag processing in "
+ "Django 2.1.",
+ RemovedInDjango21Warning
+ )
if hasattr(response, 'render') and callable(response.render):
response.add_post_render_callback(set_response_etag)
else: