Opened 9 years ago

Closed 8 years ago

#26765 closed Cleanup/optimization (fixed)

Etags should not be added when no-store is used

Reported by: Kevin Christopher Henry Owned by: nobody
Component: HTTP handling 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: no UI/UX: no

Description

Glancing at the source code, it looks like CommonMiddleware (with USE_ETAGS = True) adds an Etag whenever there isn't one already.

However, according to RFC 7234, "the no-store response directive indicates that a cache MUST NOT store any part of either the immediate request or response." Since the response must not be stored, no compliant cache will be able to issue a conditional request, so computing the Etag is wasted effort. (Note that this behavior is different from no-cache.)

The current behavior doesn't do any real harm, but we might as well improve the performance of such requests given that the change should be relatively easy (simply checking the header value).

Change History (5)

comment:1 by Tim Graham, 9 years ago

Component: Core (Cache system)HTTP handling
Triage Stage: UnreviewedAccepted

comment:2 by Tobias McNulty, 9 years ago

Has patch: set
Triage Stage: AcceptedReady for checkin

Reviewed & notes left on the PR: https://github.com/django/django/pull/6810

comment:3 by Kevin Christopher Henry, 9 years ago

Patch needs improvement: set
Triage Stage: Ready for checkinAccepted

Added comments on the PR.

comment:4 by Kevin Christopher Henry, 9 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 20d3932:

Fixed #26765 -- Made CommonMiddleware no longer set an ETag when response has Cache-Control: no-store.

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