Skip to content

Commit 05d0194

Browse files
committed
Tweaks
1 parent 7c13aae commit 05d0194

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

controller.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -545,16 +545,18 @@ Sending Early Hints
545545

546546
The Early Hints helper of the ``AbstractController`` was introduced
547547
in Symfony 6.3.
548+
.. _`Early hints`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103
549+
.. _`SAPI`: https://www.php.net/manual/en/function.php-sapi-name.php
548550

549-
Early hints allow to tell user's browser to start downloading some assets
550-
even before sending the response content. Thanks to this, the browser is able
551-
to prefetch resources that will be needed once the full response is finally sent.
552-
These resources are commonly Javascript or CSS files, but it can be any type of
553-
resource.
551+
`Early hints`_ tell the browser to start downloading some assets even before the
552+
application sends the response content. This improves perceived performance
553+
because the browser can prefetch resources that will be needed once the full
554+
response is finally sent. These resources are commonly Javascript or CSS files,
555+
but they can be any type of resource.
554556

555557
.. note::
556558

557-
In order to work, the SAPI you're using must support this feature, like
559+
In order to work, the `SAPI`_ you're using must support this feature, like
558560
`FrankenPHP`_.
559561

560562
You can send early hints from your controller action thanks to the
@@ -584,10 +586,14 @@ method::
584586
}
585587
}
586588

587-
The ``sendEarlyHints`` method will send a first informational response to the
588-
web browser with a 103 status code. If it supports it, the browser will start
589-
to download ``style.css`` and ``script.js`` while you're generating the response
590-
full content.
589+
Technically, Early Hints are an informational HTTP response with the status code
590+
``103``. The ``sendEarlyHints()`` method creates a ``Response`` object with that
591+
status code and sends its headers immediately.
592+
593+
This way, browsers can start downloading the assets immediately; like the
594+
``style.css`` and ``script.js`` files in the above example). The
595+
``sendEarlyHints()`` method also returns the ``Response`` object, which you
596+
must use to create the full response sent from the controller action.
591597

592598
Final Thoughts
593599
--------------

0 commit comments

Comments
 (0)