#7581: Middleware accessing HttpResponse.content breaks streaming HttpResponse
objects.
-------------------------------------+-------------------------------------
     Reporter:  mrmachine            |                    Owner:  ccahoon
         Type:  New feature          |                   Status:  new
    Component:  Core (Other)         |                  Version:  master
     Severity:  Normal               |               Resolution:
     Keywords:  stream HttpResponse  |             Triage Stage:  Accepted
  Content-Length                     |      Needs documentation:  1
    Has patch:  1                    |  Patch needs improvement:  1
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by mrmachine):

 I've updated the branch again slightly, to use `HttpStreamingResponse` in
 the `django.views.static.serve` view. This is MASSIVELY faster on my local
 machine. It was slightly less of an improvement with `GZipMiddleware`
 enabled, but still a huge improvement compared to regular responses.

 I noticed when I was testing a site that hosts a 16MB iPad app. When I
 tried to install the app on the iPad from my local dev/test site, it was
 *extremely* slow. So I tried to download the file directly with Firefox on
 the same machine. Firefox was pulling it down at 60-70KB/s from localhost.

 When using `HttpStreamingResponse` instead, it's instantaneous. This is
 not only useful or noticeable with large files, but in general all images
 and other static content now loads MUCH faster with the dev server.
 Previously I could literally see even small files (60KB images) being
 progressively drawn to the page. Now it's all instant. Much nicer during
 development, especially on image heavy sites.

 I also found that `django.http.utils.conditional_content_removal()` was
 accessing `response.content` directly. I've updated that to work with
 regular and streaming responses. I couldn't find *any* tests for this
 function (or any in `django.http.utils`, so I added a new regression tests
 package, `http_utils`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/7581#comment:33>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to