diff options
| author | Tim Graham <timograham@gmail.com> | 2017-09-02 21:09:22 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-09-22 12:51:18 -0400 |
| commit | 48d57788ee56811fa77cd37b9edf40535f82d87e (patch) | |
| tree | 287dccd8f73cc4ef5d0f57eb5607fa1076a75bc0 /django | |
| parent | 4502489a466b89cccd9d2c1b8d21b2f153d71b4b (diff) | |
Refs #26447 -- Removed the USE_ETAGS setting per deprecation timeline.
Diffstat (limited to 'django')
| -rw-r--r-- | django/conf/global_settings.py | 5 | ||||
| -rw-r--r-- | django/middleware/common.py | 33 | ||||
| -rw-r--r-- | django/utils/cache.py | 14 |
3 files changed, 1 insertions, 51 deletions
diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py index 754e6e5cdf..4d7c5854e2 100644 --- a/django/conf/global_settings.py +++ b/django/conf/global_settings.py @@ -21,11 +21,6 @@ DEBUG = False # on a live site. DEBUG_PROPAGATE_EXCEPTIONS = False -# Whether to use the "ETag" header. This saves bandwidth but slows down performance. -# Deprecated (RemovedInDjango21Warning) in favor of ConditionalGetMiddleware -# which sets the ETag regardless of this setting. -USE_ETAGS = False - # People who get code error notifications. # In the format [('Full Name', 'email@example.com'), ('Full Name', 'anotheremail@example.com')] ADMINS = [] diff --git a/django/middleware/common.py b/django/middleware/common.py index d8cfb9a8b0..7e520b7061 100644 --- a/django/middleware/common.py +++ b/django/middleware/common.py @@ -1,5 +1,4 @@ import re -import warnings from urllib.parse import urlparse from django.conf import settings @@ -7,10 +6,7 @@ from django.core.exceptions import PermissionDenied from django.core.mail import mail_managers from django.http import HttpResponsePermanentRedirect from django.urls import is_valid_path -from django.utils.cache import ( - cc_delim_re, get_conditional_response, set_response_etag, -) -from django.utils.deprecation import MiddlewareMixin, RemovedInDjango21Warning +from django.utils.deprecation import MiddlewareMixin class CommonMiddleware(MiddlewareMixin): @@ -30,11 +26,6 @@ class CommonMiddleware(MiddlewareMixin): This behavior can be customized by subclassing CommonMiddleware and overriding the response_redirect_class attribute. - - - ETags: If the USE_ETAGS setting is set, ETags will be calculated from - the entire page content and Not Modified responses will be returned - appropriately. USE_ETAGS is deprecated in favor of - ConditionalGetMiddleware. """ response_redirect_class = HttpResponsePermanentRedirect @@ -114,23 +105,6 @@ class CommonMiddleware(MiddlewareMixin): if self.should_redirect_with_slash(request): return self.response_redirect_class(self.get_full_path_with_slash(request)) - if settings.USE_ETAGS and self.needs_etag(response): - warnings.warn( - "The USE_ETAGS setting is deprecated in favor of " - "ConditionalGetMiddleware which sets the ETag regardless of " - "the setting. CommonMiddleware won't do ETag processing in " - "Django 2.1.", - RemovedInDjango21Warning - ) - if not response.has_header('ETag'): - set_response_etag(response) - - if response.has_header('ETag'): - return get_conditional_response( - request, - etag=response['ETag'], - response=response, - ) # Add the Content-Length header to non-streaming responses if not # already set. if not response.streaming and not response.has_header('Content-Length'): @@ -138,11 +112,6 @@ class CommonMiddleware(MiddlewareMixin): return response - def needs_etag(self, response): - """Return True if an ETag header should be added to response.""" - cache_control_headers = cc_delim_re.split(response.get('Cache-Control', '')) - return all(header.lower() != 'no-store' for header in cache_control_headers) - class BrokenLinkEmailsMiddleware(MiddlewareMixin): diff --git a/django/utils/cache.py b/django/utils/cache.py index b1abbf0648..81fc44293e 100644 --- a/django/utils/cache.py +++ b/django/utils/cache.py @@ -20,12 +20,10 @@ 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, @@ -248,18 +246,6 @@ def patch_response_headers(response, cache_timeout=None): cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS 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: - response = set_response_etag(response) if not response.has_header('Expires'): response['Expires'] = http_date(time.time() + cache_timeout) patch_cache_control(response, max_age=cache_timeout) |
