Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
9e07a9b5
Kaydet (Commit)
9e07a9b5
authored
Eyl 15, 2016
tarafından
Rinat Khabibiev
Kaydeden (comit)
Tim Graham
Eyl 28, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #27226 -- Removed patch_response_headers()'s setting of the Last-Modified header.
üst
32031718
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
8 deletions
+18
-8
cache.py
django/utils/cache.py
+2
-4
utils.txt
docs/ref/utils.txt
+4
-1
1.11.txt
docs/releases/1.11.txt
+8
-0
cache.txt
docs/topics/cache.txt
+4
-3
No files found.
django/utils/cache.py
Dosyayı görüntüle @
9e07a9b5
...
@@ -229,8 +229,8 @@ def _if_modified_since_passes(last_modified, if_modified_since):
...
@@ -229,8 +229,8 @@ def _if_modified_since_passes(last_modified, if_modified_since):
def
patch_response_headers
(
response
,
cache_timeout
=
None
):
def
patch_response_headers
(
response
,
cache_timeout
=
None
):
"""
"""
Add
s some useful headers to the given HttpResponse object:
Add
HTTP caching headers to the given HttpResponse: Expires and
ETag, Last-Modified, Expires and Cache-Control
Cache-Control.
Each header is only added if it isn't already set.
Each header is only added if it isn't already set.
...
@@ -246,8 +246,6 @@ def patch_response_headers(response, cache_timeout=None):
...
@@ -246,8 +246,6 @@ def patch_response_headers(response, cache_timeout=None):
response
.
add_post_render_callback
(
set_response_etag
)
response
.
add_post_render_callback
(
set_response_etag
)
else
:
else
:
response
=
set_response_etag
(
response
)
response
=
set_response_etag
(
response
)
if
not
response
.
has_header
(
'Last-Modified'
):
response
[
'Last-Modified'
]
=
http_date
()
if
not
response
.
has_header
(
'Expires'
):
if
not
response
.
has_header
(
'Expires'
):
response
[
'Expires'
]
=
http_date
(
time
.
time
()
+
cache_timeout
)
response
[
'Expires'
]
=
http_date
(
time
.
time
()
+
cache_timeout
)
patch_cache_control
(
response
,
max_age
=
cache_timeout
)
patch_cache_control
(
response
,
max_age
=
cache_timeout
)
...
...
docs/ref/utils.txt
Dosyayı görüntüle @
9e07a9b5
...
@@ -53,7 +53,6 @@ need to distinguish caches by the ``Accept-language`` header.
...
@@ -53,7 +53,6 @@ need to distinguish caches by the ``Accept-language`` header.
Adds some useful headers to the given ``HttpResponse`` object:
Adds some useful headers to the given ``HttpResponse`` object:
* ``ETag``
* ``ETag``
* ``Last-Modified``
* ``Expires``
* ``Expires``
* ``Cache-Control``
* ``Cache-Control``
...
@@ -62,6 +61,10 @@ need to distinguish caches by the ``Accept-language`` header.
...
@@ -62,6 +61,10 @@ need to distinguish caches by the ``Accept-language`` header.
``cache_timeout`` is in seconds. The :setting:`CACHE_MIDDLEWARE_SECONDS`
``cache_timeout`` is in seconds. The :setting:`CACHE_MIDDLEWARE_SECONDS`
setting is used by default.
setting is used by default.
.. versionchanged:: 1.11
In older versions, the ``Last-Modified`` header was also set.
.. function:: add_never_cache_headers(response)
.. function:: add_never_cache_headers(response)
Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate``
Adds a ``Cache-Control: max-age=0, no-cache, no-store, must-revalidate``
...
...
docs/releases/1.11.txt
Dosyayı görüntüle @
9e07a9b5
...
@@ -539,6 +539,14 @@ Miscellaneous
...
@@ -539,6 +539,14 @@ Miscellaneous
:rfc:`7232` Conditional Requests specification rather than the older
:rfc:`7232` Conditional Requests specification rather than the older
:rfc:`2616`.
:rfc:`2616`.
* :func:`~django.utils.cache.patch_response_headers` no longer adds a
``Last-Modified`` header. According to the :rfc:`7234#section-4.2.2`, this
header is useless alongside other caching headers that provide an explicit
expiration time, e.g. ``Expires`` or ``Cache-Control``.
:class:`~django.middleware.cache.UpdateCacheMiddleware` and
:func:`~django.utils.cache.add_never_cache_headers` call
``patch_response_headers()`` and therefore are also affected by this change.
* In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
* In the admin templates, ``<p class="help">`` is replaced with a ``<div>`` tag
to allow including lists inside help text.
to allow including lists inside help text.
...
...
docs/topics/cache.txt
Dosyayı görüntüle @
9e07a9b5
...
@@ -528,15 +528,16 @@ return a cached GET response for HEAD request.
...
@@ -528,15 +528,16 @@ return a cached GET response for HEAD request.
Additionally, ``UpdateCacheMiddleware`` automatically sets a few headers in each
Additionally, ``UpdateCacheMiddleware`` automatically sets a few headers in each
:class:`~django.http.HttpResponse`:
:class:`~django.http.HttpResponse`:
* Sets the ``Last-Modified`` header to the current date/time when a fresh
(not cached) version of the page is requested.
* Sets the ``Expires`` header to the current date/time plus the defined
* Sets the ``Expires`` header to the current date/time plus the defined
:setting:`CACHE_MIDDLEWARE_SECONDS`.
:setting:`CACHE_MIDDLEWARE_SECONDS`.
* Sets the ``Cache-Control`` header to give a max age for the page --
* Sets the ``Cache-Control`` header to give a max age for the page --
again, from the :setting:`CACHE_MIDDLEWARE_SECONDS` setting.
again, from the :setting:`CACHE_MIDDLEWARE_SECONDS` setting.
.. versionchanged:: 1.11
In older versions, the ``Last-Modified`` header was also set.
See :doc:`/topics/http/middleware` for more on middleware.
See :doc:`/topics/http/middleware` for more on middleware.
If a view sets its own cache expiry time (i.e. it has a ``max-age`` section in
If a view sets its own cache expiry time (i.e. it has a ``max-age`` section in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment