Debian Codegraph @

docs/optimizations/index.txt

raw
1 ##################
2 Optimize streaming
3 ##################
4
5 Some reverse proxies allow applications to delegate actual download to the
6 proxy:
7
8 * with Django, manage permissions, generate files...
9 * let the reverse proxy serve the file.
10
11 As a result, you get increased performance: reverse proxies are more efficient
12 than Django at serving static files.
13
14
15 ***********************
16 Supported features grid
17 ***********************
18
19 Supported features depend on backend. Given the file you want to stream, the
20 backend may or may not be able to handle it:
21
22 +-----------------------+-------------------------+-------------------------+-------------------------+
23 | View / File | :doc:`nginx` | :doc:`apache` | :doc:`lighttpd` |
24 +=======================+=========================+=========================+=========================+
25 | :doc:`/views/path` | Yes, local filesystem. | Yes, local filesystem. | Yes, local filesystem. |
26 +-----------------------+-------------------------+-------------------------+-------------------------+
27 | :doc:`/views/storage` | Yes, local and remote. | Yes, local filesystem. | Yes, local filesystem. |
28 +-----------------------+-------------------------+-------------------------+-------------------------+
29 | :doc:`/views/object` | Yes, local and remote. | Yes, local filesystem. | Yes, local filesystem. |
30 +-----------------------+-------------------------+-------------------------+-------------------------+
31 | :doc:`/views/http` | Yes. | No. | No. |
32 +-----------------------+-------------------------+-------------------------+-------------------------+
33 | :doc:`/views/virtual` | No. | No. | No. |
34 +-----------------------+-------------------------+-------------------------+-------------------------+
35
36 As an example, :doc:`Nginx X-Accel </optimizations/nginx>` handles URL for
37 internal redirects, so it can manage
38 :class:`~django_downloadview.files.HTTPFile`; whereas :doc:`Apache X-Sendfile
39 </optimizations/apache>` handles absolute path, so it can only deal with files
40 on local filesystem.
41
42 There are currently no optimizations to stream in-memory files, since they only
43 live on Django side, i.e. they do not persist after Django returned a response.
44 Note: there is `a feature request about "local cache" for streamed files`_.
45
46
47 *****************
48 How does it work?
49 *****************
50
51 View return some :class:`~django_downloadview.response.DownloadResponse`
52 instance, which itself carries a :doc:`file wrapper </files>`.
53
54 `django-downloadview` provides response middlewares and decorators that are
55 able to capture :class:`~django_downloadview.response.DownloadResponse`
56 instances and convert them to
57 :class:`~django_downloadview.response.ProxiedDownloadResponse`.
58
59 The :class:`~django_downloadview.response.ProxiedDownloadResponse` is specific
60 to the reverse-proxy (backend): it tells the reverse proxy to stream some
61 resource.
62
63 .. note::
64
65 The feature is inspired by :mod:`Django's TemplateResponse
66 <django.template.response>`
67
68
69 ***********************
70 Available optimizations
71 ***********************
72
73 Here are optimizations builtin `django_downloadview`:
74
75 .. toctree::
76 :titlesonly:
77
78 nginx
79 apache
80 lighttpd
81
82 .. note:: If you need support for additional optimizations, `tell us`_!
83
84
85 .. rubric:: Notes & references
86
87 .. target-notes::
88
89 .. _`tell us`:
90 https://github.com/jazzband/django-downloadview/issues?labels=optimizations
91 .. _`a feature request about "local cache" for streamed files`:
92 https://github.com/jazzband/django-downloadview/issues/70