Skip to content

Generate the variations of a media on creation, optionally in the background - #184

Open
rvanlaak wants to merge 3 commits into
jolicode:mainfrom
rvanlaak:feature/store-on-create
Open

rvanlaak wants to merge 3 commits into
jolicode:mainfrom
rvanlaak:feature/store-on-create

Conversation

@rvanlaak

@rvanlaak rvanlaak commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

The bundle comes from a local filesystem perspective: checking whether a variation exists is cheap, and the application serves the files, so a missing variation can be generated when requested. On a bucket, neither holds. Listing media shouldn't cost a storage request per variation, and URLs served by the bucket itself (pre-signed, a CDN) never reach the application, so a missing variation is never generated.

This adds a cache.store_on_create setting, which generates all the variations of a media when it is created or moved. Setting store_on_create_message_bus hands that generation to Symfony Messenger, so it can run in a worker. By default, generation is synchronous and Messenger isn't required.

The documentation is in doc/misc-features/url-generation.rst.

… creation

Generating variations lazily suits a local filesystem, where checking that a
file exists is cheap. On a bucket each check is a request, and variations served
without the MediaController (through a CDN or pre-signed URLs) are never
generated when missing.

With cache.store_on_create enabled, a listener converts all the applicable
variations when a media is created or moved, forcing the conversion as no
variation can be stored at that path yet.
…us is configured

The store_on_create_message_bus setting names the bus to dispatch a
StoreVariations message to, instead of generating the variations
synchronously; routing the message to an asynchronous transport moves the
generation to a worker. A setting that names no Messenger bus fails the
container compilation.
@rvanlaak

Copy link
Copy Markdown
Contributor Author

@xavierlacot any spare time to review this improvement to the generation of variations and feature to dispatch that to the background?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant