Opened 6 years ago

Closed 2 years ago

Last modified 2 years ago

#13755 closed Bug (fixed)

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

Reported by: Miloslav Pojman 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 Tim Graham 2 years ago.

Download all attachments as: .zip

Change History (10)

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

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Miloslav Pojman

Cc: miloslav.pojman@… added

comment:3 Changed 5 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:4 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

Changed 2 years ago by Tim Graham

Attachment: 13755.diff added

comment:6 Changed 2 years ago by Tim Graham

Has patch: set

comment:7 Changed 2 years ago by Claude Paroz

Triage Stage: AcceptedReady for checkin

comment:8 Changed 2 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In db9a1a0c47cacb9fa4ba7a39ffedeecf4e672223:

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

Thanks mila for the suggestion.

comment:9 Changed 2 years 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