Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7275 closed (invalid)

CacheMiddleware will break any streaming HttpResponse.

Reported by: bear330 Owned by: nobody
Component: Core (Cache system) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If view uses Http Streaming technique, it returns a HttpResponse which its content is a generator.
CacheMiddleware will break any streaming HttpResponse.

This is because it tries to pickle HttpResponse result to cache backend, but generator can't be pickled.

The view won't return anything, it just hangs.

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

If your view is returning a response with headers that indicate it shouldn't be cached (e.g., by using the never_cache decorator), this won't be a problem since the middleware won't try to cache it. And I can't see a use case for caching a dynamic streaming response, so I'm going to go ahead and mark this invalid.

comment:2 follow-up: Changed 6 years ago by jim <jim-django@…>

From the report:

The view won't return anything, it just hangs.

This is worrying. No exception was thrown? That would certainly be a bug.

comment:3 in reply to: ↑ 2 Changed 6 years ago by anonymous

Replying to jim <jim-django@dsdd.org>:

From the report:

The view won't return anything, it just hangs.

This is worrying. No exception was thrown? That would certainly be a bug.

Yes, no any exception was thrown before the generator ends.
If my generator is endless, it will hangs.
It only throws exception after everything is done.

comment:4 Changed 6 years ago by ubernostrum

If it eventually does throw an exception once the generator is consumed, that's OK. Not throwing an exception until the full response is available to look it is fine.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.