Skip to content

Commit ecc48a8

Browse files
committed
Merge branch '7.4' into 8.0
* 7.4: Minor reword Add a note that checking for flash messages defeats HTTP cacheability
2 parents 467a80d + b3ed4a6 commit ecc48a8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

session.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,17 @@ It's common to use ``notice``, ``warning`` and ``error`` as the keys of the
265265
different types of flash messages, but you can use any key that fits your
266266
needs.
267267

268+
.. tip::
269+
270+
Accessing flash messages requires starting the session, which in turn
271+
causes Symfony to mark the response as ``private``. In general, because
272+
flash messages are meant to be displayed only once, pages that might show
273+
them cannot reasonably be cached by HTTP caches.
274+
275+
As an alternative, you can load flash messages asynchronously through
276+
another HTTP request (for example, using a `Twig Live Component`_), making
277+
the original page fully cacheable.
278+
268279
Configuration
269280
-------------
270281

@@ -1526,6 +1537,7 @@ the example below:
15261537
can use the Symfony save handler without side effects and that the session
15271538
has not been started before Symfony is initialized.
15281539

1540+
.. _`Twig Live Component`: https://symfony.com/bundles/ux-live-component/current/index.html
15291541
.. _`phpredis extension`: https://github.com/phpredis/phpredis
15301542
.. _`DoctrineMongoDBBundle configuration`: https://symfony.com/doc/master/bundles/DoctrineMongoDBBundle/config.html
15311543
.. _`MongoDB shell`: https://docs.mongodb.com/manual/mongo/

0 commit comments

Comments
 (0)