Opened 13 years ago

Closed 4 years ago

#14722 closed Bug (wontfix)

@last_modified should ignore lack of etag method when USE_ETAGS is enabled.

Reported by: Chris Lamb Owned by: nobody
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Using @last_modified with settings.USE_ETAGS does not work as expected.

My goal is to avoid evaluating the view for a select handful of expensive pages based on the Last-Modified header, and globally fallback to saving bandwidth with USE_ETAGS.

However, if you enable USE_ETAGS and the @last_modified decorator, the view is still evaluated despite the last_modified_func being a match with If-Modified-Since. This is because the client is providing an ETag header (added because USE_ETAGS is enabled) and django.views.decorators.http.condition uses that etag along with the fact that we did did not provide an etag_func argument as a reason for not returning 304.

Patch attached that disables this particular part of the logic if settings.USE_ETAGS is enabled.

Attachments (2)

patch.txt (1.1 KB ) - added by Chris Lamb 13 years ago.
14722-2.diff (8.6 KB ) - added by Claude Paroz 12 years ago.
Refactoring, tests and docs

Download all attachments as: .zip

Change History (13)

by Chris Lamb, 13 years ago

Attachment: patch.txt added

comment:1 by Russell Keith-Magee, 13 years ago

Component: UncategorizedCore framework
Has patch: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:2 by Jannis Leidel, 13 years ago

I suppose this is related to r14885 and #14103, too.

comment:3 by James Addison, 13 years ago

Severity: Normal
Type: Bug

comment:4 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

by Claude Paroz, 12 years ago

Attachment: 14722-2.diff added

Refactoring, tests and docs

comment:6 by Claude Paroz, 12 years ago

Needs tests: unset
Patch needs improvement: unset

They were several issues related with condition decorator and the USE_ETAGS setting. Just run tests (especially conditional_processing) with USE_ETAGS=True in your settings to reveal errors.

My patch is solving these issues and also factorizes ETag generation at the response object level.

comment:7 by Aymeric Augustin, 11 years ago

Component: Core (Other)HTTP handling

comment:8 by Tim Graham, 10 years ago

Patch needs improvement: set

Patch needs to be updated.

comment:9 by Mariusz Felisiak, 4 years ago

Claude, Can you check is this still valid? settings.USE_ETAGS was removed in Django 2.1.

comment:10 by Claude Paroz, 4 years ago

Wow, long time ago...

Looks like https://tools.ietf.org/html/rfc7232#section-6 specifies that Etag checking has precedence over the last modified header. I'd vote for won't fixing this. Chris, any renewed opinion?

comment:11 by Mariusz Felisiak, 4 years ago

Resolution: wontfix
Status: newclosed
Summary: @last_modified should ignore lack of etag method when USE_ETAGS is enabled@last_modified should ignore lack of etag method when USE_ETAGS is enabled.
Version: 1.2master

Claude, thanks! I agree let's close this ticket as wontfix.

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