Disable upstream caching with messages framework
|Reported by:||bronger||Owned by:||nobody|
|Cc:||bronger@…||Triage Stage:||Design decision needed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Upstream caching should be disabled when messages have been consumed in the current request. I added
if request._messages.used: add_never_cache_headers(response)
to "process_response" of MessageMiddleware and it works nicely for me. Doesn't it make sense to do that always, or at least, by default?
When the message framework is used and the messages are iterared over in the current view, this means that it is posible that they are displayed and consumed. Thus, when the same page is retrieved next time, they won't appear, or with different content.
It is very difficult to handle this in cache-related code of that view because the messages have been generated in a previous request, which may even belong to another view.
Change History (5)
comment:1 Changed 6 years ago by SmileyChris
- Component changed from Uncategorized to Contrib apps
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Design decision needed
comment:3 Changed 5 years ago by gabrielhurley
- Component changed from Contrib apps to contrib.messages