Opened 6 years ago
Closed 6 years ago
#30701 closed Cleanup/optimization (fixed)
Allowing patch_vary_headers() caching utility to handle '*' value.
| Reported by: | Alexander-TX | Owned by: | Adnan Umer |
|---|---|---|---|
| Component: | Core (Cache system) | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Function "patch_vary_headers", simply appends new headers to list. If view code sets Vary header to asterisk, the resulting header (after applying SessionMiddleware and LocaleMiddleware) looks like this:
Vary: *, Accept-Language, Cookie
This is unnecessary and possible violates HTTP spec:
The "Vary" header field in a response describes what parts of a
request message, aside from the method, Host header field, and
request target, might influence the origin server's process for
selecting and representing this response. The value consists of
either a single asterisk ("*") or a list of header field names
(case-insensitive).
Vary = "*" / 1#field-name
(from https://tools.ietf.org/html/rfc7231#page-70)
I am using Django to implement REST API, so I'd like it to speak robust HTTP, that works with all present and future caching libraries, — even if widely used browsers and Nginx can correctly interpret current form of the header.
Change History (8)
comment:1 by , 6 years ago
| Component: | HTTP handling → Core (Cache system) |
|---|---|
| Summary: | Django generates overly verbose and possibly invalid Vary headers → Allowing patch_vary_headers() caching utility to handle '*' value. |
| Triage Stage: | Unreviewed → Accepted |
| Type: | Bug → New feature |
comment:2 by , 6 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:4 by , 6 years ago
| Needs documentation: | set |
|---|---|
| Version: | 2.2 → master |
comment:5 by , 6 years ago
| Needs documentation: | unset |
|---|
comment:6 by , 6 years ago
| Has patch: | set |
|---|---|
| Type: | New feature → Cleanup/optimization |
Hi Alexander. Thanks for the report.
Happy to accept this as an enhancement. (It's clear from the existing test cases that
'*'was never considered.)I was going to uncheck "Easy Pickings" but perhaps it is simple enough...