Opened 15 years ago
Closed 6 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)
Change History (13)
by , 15 years ago
comment:1 by , 15 years ago
| Component: | Uncategorized → Core framework |
|---|---|
| Has patch: | set |
| Needs tests: | set |
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 15 years ago
comment:3 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:6 by , 14 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 , 13 years ago
| Component: | Core (Other) → HTTP handling |
|---|
comment:9 by , 6 years ago
Claude, Can you check is this still valid? settings.USE_ETAGS was removed in Django 2.1.
comment:10 by , 6 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 , 6 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
| 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.2 → master |
Claude, thanks! I agree let's close this ticket as wontfix.
I suppose this is related to r14885 and #14103, too.