Some reverse proxies allow applications to delegate actual download to the proxy:
As a result, you get increased performance: reverse proxies are more efficient than Django at serving static files.
Currently, only nginx’s X-Accel [1] is supported, but contributions are welcome [2]!
The feature is inspired by Django’s TemplateResponse [3]: the download views return some django_downloadview.response.DownloadResponse instance. Such a response doesn’t contain file data.
By default, at the end of Django’s request/response handling, Django is to iterate over the content attribute of the response. In a DownloadResponse, this content attribute is a file wrapper.
It means that decorators and middlewares are given an opportunity to capture the DownloadResponse before the content of the file is loaded into memory As an example, django_downloadview.nginx.XAccelRedirectMiddleware replaces DownloadResponse intance by some django_downloadview.nginx.XAccelRedirectResponse.
References
[1] | http://wiki.nginx.org/X-accel |
[2] | https://github.com/benoitbryon/django-downloadview/issues?labels=optimizations |
[3] | https://docs.djangoproject.com/en/1.5/ref/template-response/ |