Skip to content

[AssetMapper] Shortening "Optimizing Performance" #19609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions frontend/asset_mapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -631,27 +631,25 @@ To make your AssetMapper-powered site fly, there are a few things you need to
do. If you want to take a shortcut, you can use a service like `Cloudflare`_,
which will automatically do most of these things for you:

- **Use HTTP/2**: Your web server **must** be running HTTP/2 (or HTTP/3) so the
- **Use HTTP/2**: Your web server should be running HTTP/2 (or HTTP/3) so the
browser can download assets in parallel. HTTP/2 is automatically enabled in Caddy
and can be activated in Nginx and Apache. Or, proxy your site through a
service like Cloudflare, which will automatically enable HTTP/2 for you.
and can be activated in Nginx and Apache.

- **Compress your assets**: Your web server should compress (e.g. using gzip)
your assets (JavaScript, CSS, images) before sending them to the browser. This
is automatically enabled in Caddy and can be activated in Nginx and Apache.
Or, proxy your site through a service like Cloudflare, which will
automatically compress your assets for you. In Cloudflare, you can also
In Cloudflare, you can also
enable `auto minify`_ to further compress your assets (e.g. removing
whitespace and comments from JavaScript and CSS files).

- **Set long-lived Expires headers**: Your web server should set long-lived
Expires headers on your assets. Because the AssetMapper component includes a version
hash in the filename of each asset, you can safely set the Expires header
``Expires`` HTTP headers on your assets. Because the AssetMapper component includes a version
hash in the filename of each asset, you can safely set the ``Expires`` header
to a very long time in the future (e.g. 1 year). This isn't automatic in
any web server, but can be easily enabled.

Once you've done these things, you can use a tool like `Lighthouse`_ to
validate the performance of your site!
check the performance of your site.

.. _performance-preloading:

Expand Down