Opened 3 years ago

Closed 3 years ago

#32335 closed Bug (invalid)

Cache Control decorator should not cache 500 status code responses

Reported by: Varun Patil Owned by: Varun Patil
Component: Error reporting Version: dev
Severity: Normal Keywords: cache control bad response decorator
Cc: Varun Patil Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Varun Patil)

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

Change History (4)

comment:1 by Varun Patil, 3 years ago

Description: modified (diff)

comment:2 by Varun Patil, 3 years ago

Cc: Varun Patil added
Owner: set to Varun Patil
Status: newassigned

comment:3 by Varun Patil, 3 years ago

Has patch: unset

comment:4 by Varun Patil, 3 years ago

Resolution: invalid
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top