Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#7275 closed (invalid)

CacheMiddleware will break any streaming HttpResponse.

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

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.

Change History (4)

comment:1 by James Bennett, 16 years ago

Resolution: invalid
Status: newclosed

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 by jim <jim-django@…>, 16 years ago

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.

in reply to:  2 comment:3 by anonymous, 16 years ago

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 by James Bennett, 16 years ago

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.

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