@@ -545,16 +545,18 @@ Sending Early Hints
545
545
546
546
The Early Hints helper of the ``AbstractController `` was introduced
547
547
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
548
550
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.
554
556
555
557
.. note ::
556
558
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
558
560
`FrankenPHP `_.
559
561
560
562
You can send early hints from your controller action thanks to the
@@ -584,10 +586,14 @@ method::
584
586
}
585
587
}
586
588
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.
591
597
592
598
Final Thoughts
593
599
--------------
0 commit comments