|
3 | 3 | Common Deployment Scenarios
|
4 | 4 | ===========================
|
5 | 5 |
|
6 |
| -This document presents the most typical scenarios in which Django Compressor can be |
7 |
| -configured, and should help you decide which method you may want to use for your stack. |
| 6 | +This document presents the most typical scenarios in which Django Compressor |
| 7 | +can be configured, and should help you decide which method you may want to |
| 8 | +use for your stack. |
8 | 9 |
|
9 | 10 | In-Request Compression
|
10 |
| --------- |
| 11 | +---------------------- |
11 | 12 |
|
12 |
| -This is the default method of compression. Where-in Django Compressor will go through |
13 |
| -the steps outlined in :ref:`behind_the_scenes`. You will find in-request compression beneficial if: |
| 13 | +This is the default method of compression. Where-in Django Compressor will |
| 14 | +go through the steps outlined in :ref:`behind_the_scenes`. You will find |
| 15 | +in-request compression beneficial if: |
14 | 16 |
|
15 |
| -* Using a single server setup, where the application and static files are on the same machine. |
| 17 | +* Using a single server setup, where the application and static files are on |
| 18 | + the same machine. |
16 | 19 |
|
17 |
| -* Prefer a simple configuration. By default, there is no configuration required. |
| 20 | +* Prefer a simple configuration. By default, there is no configuration |
| 21 | + required. |
18 | 22 |
|
19 | 23 | Caveats
|
20 |
| ----- |
| 24 | +------- |
21 | 25 |
|
22 |
| -* If deploying to a multi-server setup and using :attr:`~django.conf.settings.COMPRESS_PRECOMPILERS`, each binary is required to be installed on each application server. |
| 26 | +* If deploying to a multi-server setup and using |
| 27 | + :attr:`~django.conf.settings.COMPRESS_PRECOMPILERS`, each binary is |
| 28 | + required to be installed on each application server. |
23 | 29 |
|
24 |
| -* Application servers may not have permissions to write to your static directories. For example, if deploying to a CDN (e.g. Amazon S3) |
| 30 | +* Application servers may not have permissions to write to your static |
| 31 | + directories. For example, if deploying to a CDN (e.g. Amazon S3) |
25 | 32 |
|
26 | 33 | Offline Compression
|
27 |
| --------- |
| 34 | +------------------- |
28 | 35 |
|
29 |
| -This method decouples the compression outside of the request (see :ref:`behind_the_Scenes`) and can prove beneficial in the speed, and in many scenarios, the maintainability of your deployment. You will find offline compression beneficial if: |
| 36 | +This method decouples the compression outside of the request |
| 37 | +(see :ref:`behind_the_Scenes`) and can prove beneficial in the speed, |
| 38 | +and in many scenarios, the maintainability of your deployment. |
| 39 | +You will find offline compression beneficial if: |
30 | 40 |
|
31 |
| -* Using a multi-server setup. A common scenario for this may be multiple application servers and a single static file server (CDN included). With offline compression, you typically run ``manage.py compress`` on a single utility server, meaning you only maintain :attr:`~django.conf.settings.COMPRESS_PRECOMPILERS` binaries in one location. |
| 41 | +* Using a multi-server setup. A common scenario for this may be multiple |
| 42 | + application servers and a single static file server (CDN included). |
| 43 | + With offline compression, you typically run ``manage.py compress`` |
| 44 | + on a single utility server, meaning you only maintain |
| 45 | + :attr:`~django.conf.settings.COMPRESS_PRECOMPILERS` binaries in one |
| 46 | + location. |
32 | 47 |
|
33 | 48 | * You store compressed files on a CDN.
|
34 | 49 |
|
35 | 50 | Caveats
|
36 |
| ----- |
37 |
| - |
38 |
| -* If your templates have complex logic in how template inheritance is done (e.g. ``{% extends context_variable %}``), then this becomes a problem, as offline compression will not have the context, unless you set it in :attr:`~django.conf.settings.COMPRESS_OFFLINE_CONTEXT` |
39 |
| - |
40 |
| -* Due to the way the manifest file is used, While deploying across a multi-server setup, your application may use old templates with a new manifest, possibly rendering your pages incoherent. The current suggested solution for this is to change the :attr:`~django.conf.settings.COMPRESS_OFFLINE_MANIFEST` path for each new version of your code. This will ensure that the old code uses old compressed output, and the new one appropriately as well. |
41 |
| - |
42 |
| -Every setup is unique, and your scenario may differ slightly. Choose what is the most sane to maintain for your situation. |
| 51 | +------- |
| 52 | + |
| 53 | +* If your templates have complex logic in how template inheritance is done |
| 54 | + (e.g. ``{% extends context_variable %}``), then this becomes a problem, |
| 55 | + as offline compression will not have the context, unless you set it in |
| 56 | + :attr:`~django.conf.settings.COMPRESS_OFFLINE_CONTEXT` |
| 57 | + |
| 58 | +* Due to the way the manifest file is used, while deploying across a |
| 59 | + multi-server setup, your application may use old templates with a new |
| 60 | + manifest, possibly rendering your pages incoherent. The current suggested |
| 61 | + solution for this is to change the |
| 62 | + :attr:`~django.conf.settings.COMPRESS_OFFLINE_MANIFEST` path for each new |
| 63 | + version of your code. This will ensure that the old code uses old |
| 64 | + compressed output, and the new one appropriately as well. |
| 65 | + |
| 66 | +Every setup is unique, and your scenario may differ slightly. Choose what |
| 67 | +is the most sane to maintain for your situation. |
0 commit comments