summaryrefslogtreecommitdiff
path: root/django/utils/cache.py
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2022-11-04 12:33:09 +0000
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-11-10 13:52:17 +0100
commit9bd174b9a75299dce33e673a559f2b673399b971 (patch)
tree1deaac147ece269ef6a895986291d536ed334c49 /django/utils/cache.py
parentfad070b07b8c5f5022c2867d291cb6968709f2a1 (diff)
downloaddjango-9bd174b9a75299dce33e673a559f2b673399b971.tar.gz
Updated documentation and comments for RFC updates.
- Updated references to RFC 1123 to RFC 5322 - Only partial as RFC 5322 sort of sub-references RFC 1123. - Updated references to RFC 2388 to RFC 7578 - Except RFC 2388 Section 5.3 which has no equivalent. - Updated references to RFC 2396 to RFC 3986 - Updated references to RFC 2616 to RFC 9110 - Updated references to RFC 3066 to RFC 5646 - Updated references to RFC 7230 to RFC 9112 - Updated references to RFC 7231 to RFC 9110 - Updated references to RFC 7232 to RFC 9110 - Updated references to RFC 7234 to RFC 9111 - Tidied up style of text when referring to RFC documents
Diffstat (limited to 'django/utils/cache.py')
-rw-r--r--django/utils/cache.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 90292ce4da..2dd2c7796c 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -4,9 +4,7 @@ managing the "Vary" header of responses. It includes functions to patch the
header of response objects directly and decorators that change functions to do
that header-patching themselves.
-For information on the Vary header, see:
-
- https://tools.ietf.org/html/rfc7231#section-7.1.4
+For information on the Vary header, see RFC 9110 Section 12.5.5.
Essentially, the "Vary" HTTP header defines which headers a cache should take
into account when building its cache key. Requests with the same path but
@@ -139,7 +137,7 @@ def _precondition_failed(request):
def _not_modified(request, response=None):
new_response = HttpResponseNotModified()
if response:
- # Preserve the headers required by Section 4.1 of RFC 7232, as well as
+ # Preserve the headers required by RFC 9110 Section 15.4.5, as well as
# Last-Modified.
for header in (
"Cache-Control",
@@ -177,7 +175,9 @@ def get_conditional_response(request, etag=None, last_modified=None, response=No
if_modified_since = request.META.get("HTTP_IF_MODIFIED_SINCE")
if_modified_since = if_modified_since and parse_http_date_safe(if_modified_since)
- # Step 1 of section 6 of RFC 7232: Test the If-Match precondition.
+ # Evaluation of request preconditions below follows RFC 9110 Section
+ # 13.2.2.
+ # Step 1: Test the If-Match precondition.
if if_match_etags and not _if_match_passes(etag, if_match_etags):
return _precondition_failed(request)
@@ -212,7 +212,7 @@ def get_conditional_response(request, etag=None, last_modified=None, response=No
def _if_match_passes(target_etag, etags):
"""
- Test the If-Match comparison as defined in section 3.1 of RFC 7232.
+ Test the If-Match comparison as defined in RFC 9110 Section 13.1.1.
"""
if not target_etag:
# If there isn't an ETag, then there can't be a match.
@@ -233,15 +233,15 @@ def _if_match_passes(target_etag, etags):
def _if_unmodified_since_passes(last_modified, if_unmodified_since):
"""
- Test the If-Unmodified-Since comparison as defined in section 3.4 of
- RFC 7232.
+ Test the If-Unmodified-Since comparison as defined in RFC 9110 Section
+ 13.1.4.
"""
return last_modified and last_modified <= if_unmodified_since
def _if_none_match_passes(target_etag, etags):
"""
- Test the If-None-Match comparison as defined in section 3.2 of RFC 7232.
+ Test the If-None-Match comparison as defined in RFC 9110 Section 13.1.2.
"""
if not target_etag:
# If there isn't an ETag, then there isn't a match.
@@ -260,7 +260,8 @@ def _if_none_match_passes(target_etag, etags):
def _if_modified_since_passes(last_modified, if_modified_since):
"""
- Test the If-Modified-Since comparison as defined in section 3.3 of RFC 7232.
+ Test the If-Modified-Since comparison as defined in RFC 9110 Section
+ 13.1.3.
"""
return not last_modified or last_modified > if_modified_since