#14103 closed (fixed)
Have django.utils.cache.patch_response_headers honor settings.USE_ETAGS setting
Reported by: | trbs | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Keywords: | use_etags, patch_response_headers | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.
Attachments (4)
Change History (10)
by , 14 years ago
Attachment: | django_utils_cache_honor_use_etags.diff added |
---|
by , 14 years ago
Attachment: | cache_honor_use_etags.diff added |
---|
comment:1 by , 14 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 14 years ago
Attachment: | django_utils_cache_honor_use_etags_plus_test.diff added |
---|
comment:3 by , 14 years ago
Needs tests: | unset |
---|
by , 14 years ago
Attachment: | 14103_with_docs.diff added |
---|
comment:4 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Added a patch that mentions this other usage in the documentation. I didn't see the etag header specifically mentioned in the caching middleware docs, but it might be worth adding a note there about the USE_ETAG setting as well. Otherwise I think this is RFC.
comment:5 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Either of these patches look good to me, though I prefer the first slightly. This needs tests, then I think it's ready to go.