[Django] #32335: Cache Control decorator should not cache 500 status code responses

15 views
Skip to first unread message

Django

unread,
Jan 8, 2021, 3:12:14 PM1/8/21
to django-...@googlegroups.com
#32335: Cache Control decorator should not cache 500 status code responses
-------------------------------------+-------------------------------------
Reporter: | Owner: (none)
varunpatil |
Type: Bug | Status: new
Component: Error | Version: master
reporting | Keywords: cache control bad
Severity: Normal | response decorator
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
cache control decorator in 'django.views.decorators.cache' caches "bad"
responses.

If something goes wrong in my view and it returns a 500 response, I dont
want that to be cached.
According to https://developer.mozilla.org/en-
US/docs/Web/HTTP/Caching#targets_of_caching_operations , only 200, 301,
404, 206 are generally cached.

This can be quickly fixed in 'django.utils.cache.patch_cache_control' by
checking if the response code is among the ones specified above. Or
optionally, let the user decide which status codes to be cached/not cached

--
Ticket URL: <https://code.djangoproject.com/ticket/32335>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 8, 2021, 3:17:30 PM1/8/21
to django-...@googlegroups.com
#32335: Cache Control decorator should not cache 500 status code responses
-------------------------------------+-------------------------------------
Reporter: Varun Patil | Owner: (none)
Type: Bug | Status: new
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: cache control bad | Triage Stage:
response decorator | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Varun Patil:

Old description:

> cache control decorator in 'django.views.decorators.cache' caches "bad"
> responses.
>
> If something goes wrong in my view and it returns a 500 response, I dont
> want that to be cached.
> According to https://developer.mozilla.org/en-
> US/docs/Web/HTTP/Caching#targets_of_caching_operations , only 200, 301,
> 404, 206 are generally cached.
>
> This can be quickly fixed in 'django.utils.cache.patch_cache_control' by
> checking if the response code is among the ones specified above. Or
> optionally, let the user decide which status codes to be cached/not
> cached

New description:

cache control decorator in 'django.views.decorators.cache' caches "bad"
responses.

If something goes wrong in my view and it returns a 500 response, I dont
want that to be cached.
According to https://developer.mozilla.org/en-
US/docs/Web/HTTP/Caching#targets_of_caching_operations , only 200, 301,
404, 206 are generally cached.

This can be quickly fixed in 'django.utils.cache.patch_cache_control' by
checking if the response code is among the ones specified above. Or
optionally, let the user decide which status codes to be cached/not cached

other links:
https://tools.ietf.org/html/rfc7231#section-6.1

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32335#comment:1>

Django

unread,
Jan 8, 2021, 3:27:52 PM1/8/21
to django-...@googlegroups.com
#32335: Cache Control decorator should not cache 500 status code responses
-------------------------------------+-------------------------------------
Reporter: Varun Patil | Owner: Varun
| Patil
Type: Bug | Status: assigned

Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: cache control bad | Triage Stage:
response decorator | Unreviewed
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Patil):

* cc: Varun Patil (added)
* owner: (none) => Varun Patil
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/32335#comment:2>

Django

unread,
Jan 10, 2021, 3:43:26 PM1/10/21
to django-...@googlegroups.com
#32335: Cache Control decorator should not cache 500 status code responses
-------------------------------------+-------------------------------------
Reporter: Varun Patil | Owner: Varun
| Patil
Type: Bug | Status: assigned
Component: Error reporting | Version: master
Severity: Normal | Resolution:
Keywords: cache control bad | Triage Stage:
response decorator | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Patil):

* has_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/32335#comment:3>

Django

unread,
Jan 10, 2021, 4:32:48 PM1/10/21
to django-...@googlegroups.com
#32335: Cache Control decorator should not cache 500 status code responses
-------------------------------------+-------------------------------------
Reporter: Varun Patil | Owner: Varun
| Patil
Type: Bug | Status: closed

Component: Error reporting | Version: master
Severity: Normal | Resolution: invalid

Keywords: cache control bad | Triage Stage:
response decorator | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Varun Patil):

* status: assigned => closed
* resolution: => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/32335#comment:4>

Reply all
Reply to author
Forward
0 new messages