Have django.utils.cache.patch_response_headers honor settings.USE_ETAGS setting
|Reported by:||trbs||Owned by:||nobody|
|Component:||Core (Cache system)||Version:||master|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
To be able to exactly tune when your site is setting ETags on request response objects it needs to be configurable for the Django caching system.
Since we already have the the settings.USE_ETAGS configuration setting this seems the logical choice :)
Documentation states "USE_ETAGS: Whether to use the "Etag" header." and does not specify that this is only valid for CommonMiddleware.
The 'offending' function is patch_response_headers which adds some useful headers to the response object; one of these is the ETag.
However is does not honor the settings.USE_ETAGS setting from the site configuration. This means you can see ETag headers in the responses while having ETag explicitly disabled.
Patch django_utils_cache_honor_use_etags.diff attached simple adds the check for settings.USE_ETAGS to patch_response_headers.
Second patch cache_honor_use_etags.diff does basically the same thing but introduces a new setting CACHE_MIDDLEWARE_USE_ETAGS
which defaults to settings.USE_ETAGS so it can be enabled/disabled separately to USE_ETAGS.
Change History (10)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|