Opened 4 years ago

Last modified 4 years ago

#32335 closed Bug

Cache Control decorator should not cache 500 status code responses — at Version 1

Reported by: Varun Patil Owned by:
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 (1)

comment:1 by Varun Patil, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top