Opened 12 years ago
Closed 12 years ago
#20459 closed Cleanup/optimization (fixed)
Better example for setting header fields in documentation
Reported by: | bbjay | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | bbjay | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I think the current example for setting header fields in HttpResponse objects is a bit unfortunate:
https://docs.djangoproject.com/en/dev/ref/request-response/#setting-header-fields
The Cache-Control field (also the Vary field) is a comma-separated multi value field.
e.g. Cache-Control: public, max-age=60
Setting its value by a dictionary access can unintentionally remove other present values, e.g. set by another middleware.
My proposed solution: change example to use 'Age' header field, mention and encourage use of patch_vary_header and patch_cache_control methods.
https://github.com/bbjay/django/commit/227f4bf4fe7971754ecc09aeb141b824a3f0550b
Change History (5)
comment:1 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 12 years ago
comment:3 by , 12 years ago
Cool. Yes, i will gladly do that, just wanted to hear another opinion before filling a PR.
btw: do i need to set myself to cc to get updates for this ticket by email?
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
That fix looks nice. Would you care to create pull request etc., or should someone else do that?