Opened 6 weeks ago

Closed 5 weeks 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: master
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 Changed 6 weeks ago by Carlton Gibson

Component: HTTP handlingCore (Cache system)
Summary: Django generates overly verbose and possibly invalid Vary headersAllowing patch_vary_headers() caching utility to handle '*' value.
Triage Stage: UnreviewedAccepted
Type: BugNew feature

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...

comment:2 Changed 6 weeks ago by Adnan Umer

Owner: changed from nobody to Adnan Umer
Status: newassigned

comment:3 Changed 6 weeks ago by Adnan Umer

comment:4 Changed 6 weeks ago by felixxm

Needs documentation: set
Version: 2.2master

comment:5 Changed 5 weeks ago by Adnan Umer

Needs documentation: unset

comment:6 Changed 5 weeks ago by felixxm

Has patch: set
Type: New featureCleanup/optimization

comment:7 Changed 5 weeks ago by Carlton Gibson

Triage Stage: AcceptedReady for checkin

PR Looks good.

comment:8 Changed 5 weeks ago by Mariusz Felisiak <felisiak.mariusz@…>

Resolution: fixed
Status: assignedclosed

In 6805c0f9:

Fixed #30701 -- Updated patch_vary_headers() to handle an asterisk according to RFC 7231.

Note: See TracTickets for help on using tickets.
Back to Top