Opened 5 years ago

Last modified 5 years ago

#30812 closed Cleanup/optimization

ConditionalGetMiddleware returns 304 if ETag is the same but Last-Modified has changed. — at Version 1

Reported by: Flavio Curella Owned by: nobody
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mariusz Felisiak)

ConditionalGetMiddleware in combination with apache x-sendfile (django-sendfile) doesn't work properly.

Each response gets a ETag generated based on response.content which is an empty string in the case of a x-sendfile response, so each time the file is accessed, the ETag generated by ConditionalGetMiddleware is the same. Regardless of the changed file/changed mtime. In get_conditional_response() the ETag (which is always the same hash of empty string) is checked first and returns a 304 because it ignores Last-Modified time. Django shouldn't return 304 if ETag is the same but Last-Modified has changed.

Related with #29241.

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Description: modified (diff)
Summary: Return a 304 if ETag is the same but Last-Modified has changedConditionalGetMiddleware returns 304 if ETag is the same but Last-Modified has changed.
Triage Stage: UnreviewedAccepted
Version: 2.2master

Thanks for the ticket (please try to add more descriptive description in the future).

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