Fixed #26447 -- Deprecated settings.USE_ETAGS in favor of ConditionalGetMiddleware.

This commit is contained in:
Denis Cornehl 2016-04-03 12:15:10 +02:00 committed by Tim Graham
parent 46a3d7604e
commit a840710e1e
15 changed files with 126 additions and 24 deletions

View file

@ -72,6 +72,12 @@ Adds a few conveniences for perfectionists:
Older versions didn't set the ``Content-Length`` header.
.. deprecated:: 1.11
The :setting:`USE_ETAGS` setting is deprecated in favor of using
:class:`~django.middleware.http.ConditionalGetMiddleware` for ETag
processing.
.. attribute:: CommonMiddleware.response_redirect_class
Defaults to :class:`~django.http.HttpResponsePermanentRedirect`. Subclass
@ -166,13 +172,18 @@ Conditional GET middleware
.. class:: ConditionalGetMiddleware
Handles conditional GET operations. If the response has a ``ETag`` or
Handles conditional GET operations. If the response doesn't have an ``ETag``
header, the middleware adds one if needed. If the response has a ``ETag`` or
``Last-Modified`` header, and the request has ``If-None-Match`` or
``If-Modified-Since``, the response is replaced by an
:class:`~django.http.HttpResponseNotModified`.
Also sets the ``Date`` and ``Content-Length`` response-headers.
.. versionchanged:: 1.11
In older versions, the middleware didn't set the ``ETag`` header.
Locale middleware
-----------------

View file

@ -2532,6 +2532,11 @@ bandwidth but slows down performance. This is used by the
:class:`~django.middleware.common.CommonMiddleware` and in the :doc:`cache
framework </topics/cache>`.
.. deprecated:: 1.11
This setting is deprecated in favor of using ``ConditionalGetMiddleware``,
which sets an ETag regardless of this setting.
.. setting:: USE_I18N
``USE_I18N``

View file

@ -65,6 +65,11 @@ need to distinguish caches by the ``Accept-language`` header.
In older versions, the ``Last-Modified`` header was also set.
.. deprecated:: 1.11
Since the ``USE_ETAGS`` setting is deprecated, this function won't set
the ``ETag`` header when the deprecation ends in Django 2.1.
.. function:: add_never_cache_headers(response)
Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate``