Opened 5 years ago

Last modified 12 months ago

#14722 new Bug

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

Reported by: lamby 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

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 lamby 5 years ago.
14722-2.diff (8.6 KB) - added by claudep 3 years ago.
Refactoring, tests and docs

Download all attachments as: .zip

Change History (10)

Changed 5 years ago by lamby

comment:1 Changed 4 years ago by russellm

  • Component changed from Uncategorized to Core framework
  • Has patch set
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by jezdez

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

comment:3 Changed 4 years ago by jaddison

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:5 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

Changed 3 years ago by claudep

Refactoring, tests and docs

comment:6 Changed 3 years ago by claudep

  • 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 2 years ago by aaugustin

  • Component changed from Core (Other) to HTTP handling

comment:8 Changed 12 months ago by timo

  • Patch needs improvement set

Patch needs to be updated.

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