#37290: Update UpdateCacheMiddleware to mark a response as cached
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: Django Sprints
Schilling |
Type: | Status: assigned
Uncategorized |
Component: Core | Version: dev
(Cache system) | Keywords: headers, caching,
Severity: Normal | cache_page
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When caching a response, `UpdateCacheMiddleware` could mark the response
such that other logic can determine if the response was already cached.
This would allow us to emit warnings that responses are cached
unexpectedly. The point here is to help Django apps know when using
`@cache_page` that it's caching the response before other middlewares or
decorators are able to weigh in. This is related to #15855
The `decorator_from_middleware` that `@cache_page` uses, and the
challenges of it was discussed here:
https://groups.google.com/g/django-
developers/c/-W6YIlT75cM
The following should be updated to check if a response has been cached to
emit a warning.
- `@csrf_protect`
- `@patch_vary_headers`
- `@vary_on_headers` (vary_on_cookie)
- `ContentSecurityPolicyMiddleware.process_response`
- `HttpResponseBase.set_cookie` (maybe? this is due to
`SessionMiddleware.process_response`)
I think the warning messages may need to be tailored for the particular
cases.
--
Ticket URL: <
https://code.djangoproject.com/ticket/37290>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.