Opened 5 years ago

Closed 10 months ago

Last modified 10 months ago

#13755 closed Bug (fixed)

HttpRequest.is_ajax() should be used together with vary_on_headers('HTTP_X_REQUESTED_WITH')

Reported by: mila Owned by: nobody
Component: Documentation Version: 1.0
Severity: Normal Keywords:
Cc: miloslav.pojman@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Sending different response depending on HttpRequest.is_ajax() breaks Django cache middleware (an possibly others).

Easy fix is use vary_on_headers('HTTP_X_REQUESTED_WITH') decorator and I think this practice should be documented near is_ajax method http://docs.djangoproject.com/en/1.2/ref/request-response/#django.http.HttpRequest.is_ajax

Attachments (1)

13755.diff (844 bytes) - added by timo 10 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by mila

  • Cc miloslav.pojman@… added

comment:3 Changed 4 years ago by julien

  • 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 10 months ago by timo

comment:6 Changed 10 months ago by timo

  • Has patch set

comment:7 Changed 10 months ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:8 Changed 10 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In db9a1a0c47cacb9fa4ba7a39ffedeecf4e672223:

Fixed #13755 -- Added a tip for caching responses that vary on AJAX.

Thanks mila for the suggestion.

comment:9 Changed 10 months ago by Tim Graham <timograham@…>

In accdc448bc5c203503cac7cce92e17c6910038ed:

[1.7.x] Fixed #13755 -- Added a tip for caching responses that vary on AJAX.

Thanks mila for the suggestion.

Backport of db9a1a0c47 from master

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