Skip to content

Commit b8d2aef

Browse files
Add documentation about image formats for multi server setup (#847)
Co-authored-by: Prokyonn <daniel.mathis@sector8.eu>
1 parent 93bc7f1 commit b8d2aef

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

cookbook/multi-server-setup.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,30 @@ for your media files.
2626
path_prefix: 'optional path prefix'
2727
region: 'eu-west-1'
2828
29+
Image Formats
30+
-------------
31+
32+
In the Media Storage, only original files are stored. The image formats are generated by Sulu the first time they are
33+
requested. That mechanism (reverse proxy cache) is not supported by storages like S3, Blob Storage, etc. So for
34+
every server, the image will be regenerated once. As long as no media are removed, that might not be a problem.
35+
You can configure ``bin/console sulu:media:format:cache:cleanup`` as a cron job per server to ensure that an image
36+
format is also removed on all servers.
37+
38+
Still, in Kubernetes/container setups where you might lose the ``public/uploads/media`` directory every time a container restarts,
39+
you need to find different ways to cache images.
40+
You can make the ``public/uploads/media`` directory a mounted volume shared between all containers (which might not be good for performance).
41+
It is better to use some kind of CDN (Cloudflare, Fastly, etc.) or a reverse proxy cache via Nginx to cache generated image formats.
42+
43+
If you configure a CDN/reverse proxy correctly, you do not require the cron job and can disable the image format filesystem cache completely via:
44+
45+
.. code-block:: yaml
46+
47+
# config/packages/sulu_media.yaml
48+
sulu_media:
49+
format_cache:
50+
save_image: false
51+
52+
Never disable the image format cache if you do not use a CDN or reverse proxy cache that caches files for a very long time.
2953

3054
HTTP Cache
3155
----------
@@ -101,4 +125,3 @@ Alternatively, you can set a centralized ``session.save_handler`` directly in yo
101125
.. _Store Sessions in a Database: https://symfony.com/doc/current/session/database.html
102126
.. _configure a centralized caching adapter: https://symfony.com/doc/current/cache.html
103127
.. _configure Elasticsearch as a centralized search adapter: https://massivesearchbundle.readthedocs.io/en/latest/search_adapters.html#elasticsearch
104-

0 commit comments

Comments
 (0)