Opened 4 years ago

Last modified 4 years ago

#32335 closed Bug

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

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

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

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top