Opened 9 years ago

Last modified 5 years ago

#14722 new Bug

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

Reported by: Chris Lamb Owned by: nobody
Component: HTTP handling Version: 1.2
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


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 9 years ago.
14722-2.diff (8.6 KB) - added by Claude Paroz 7 years ago.
Refactoring, tests and docs

Download all attachments as: .zip

Change History (10)

Changed 9 years ago by Chris Lamb

Attachment: patch.txt added

comment:1 Changed 8 years ago by Russell Keith-Magee

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

comment:2 Changed 8 years ago by Jannis Leidel

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

comment:3 Changed 8 years ago by James Addison

Severity: Normal
Type: Bug

comment:4 Changed 7 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 7 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

Changed 7 years ago by Claude Paroz

Attachment: 14722-2.diff added

Refactoring, tests and docs

comment:6 Changed 7 years ago by Claude Paroz

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 Changed 6 years ago by Aymeric Augustin

Component: Core (Other)HTTP handling

comment:8 Changed 5 years ago by Tim Graham

Patch needs improvement: set

Patch needs to be updated.

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