Skip to content

Commit

Permalink
[AssetMapper] mention Zopfli pre-compression and add config for web s…
Browse files Browse the repository at this point in the history
…ervers
  • Loading branch information
dunglas committed Dec 7, 2024
1 parent 58e825a commit 3f46f55
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion frontend/asset_mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ installed the following PHP extensions or CLI commands:

* Brotli: ``brotli`` CLI command; `brotli PHP extension`_;
* Zstandard: ``zstd`` CLI command; `zstd PHP extension`_;
* gzip: ``gzip`` CLI command; `zlib PHP extension`_.
* gzip: ``zopfli`` (better) or ``gzip`` CLI command; `zlib PHP extension`_.

Then, update your AssetMapper configuration to define which compression to use
and which file extensions should be compressed:
Expand All @@ -751,6 +751,29 @@ compressed files are created with the same name as the original but with the
precompression will use the compressed assets automatically, so there's nothing
else to configure in your server.

Finally, you need to configure your web server to serve the precompressed assets
instead of the original ones.

For example, with FrankenPHP and Caddy, you can use the following:

.. configuration-block::

.. code-block:: caddy
file_server {
precompressed br zstd gzip

Check failure on line 764 in frontend/asset_mapper.rst

View workflow job for this annotation

GitHub Actions / Code Blocks

[PHP syntax] Syntax error, unexpected T_STRING
}
.. code-block:: nginx
gzip_static on;
# Requires https://github.com/google/ngx_brotli
brotli_static on;
# Requires https://github.com/tokers/zstd-nginx-module
zstd_static on;
.. tip::

AssetMapper provides an ``assets:compress`` CLI command and a service called
Expand Down

0 comments on commit 3f46f55

Please sign in to comment.