Skip to content

Commit afb5fdd

Browse files
committed
clarify user context and caching interaction
1 parent 2ef29fe commit afb5fdd

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

doc/symfony-cache-configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ the ``session_name_prefix`` option) in the requests to the backend. If you need
183183
a different behavior, overwrite ``UserContextSubscriber::cleanupHashLookupRequest``
184184
with your own logic.
185185

186+
.. _symfonycache_customttl:
187+
186188
Custom TTL
187189
~~~~~~~~~~
188190

doc/user-context.rst

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,21 @@ information), rather than individually.
1313

1414
.. caution::
1515

16-
Whenever you share caches, make sure to not output any individual content
16+
Whenever you share caches, make sure to **not output any individual content**
1717
like the user name. If you have individual parts of a page, you can load
18-
those parts over AJAX requests or look into ESI_. Both approaches integrate
19-
with the concepts presented in this chapter.
18+
those parts over AJAX requests or look into ESI_ and make the ESI sub
19+
response vary on the cookie or completely uncached. Both approaches
20+
integrate with the concepts presented in this chapter.
21+
22+
You do **not want intermediary proxies to cache responses** that depend on the
23+
context. If the client will not see a difference when his context changes
24+
(e.g. is removed from or added to groups on server side), you also do not
25+
want the clients to cache pages. Because ``VARY`` is used for the control
26+
of the caching proxy, it is not available to control clients. Often, the
27+
best solution is to mark your pages as private with a max-age of 0 and use
28+
the *custom TTL* mechanism (see the documentation for
29+
:ref:`Varnish <varnish_customttl>` or the
30+
:ref:`Symfony HttpCache <symfonycache_customttl>`).
2031

2132
Overview
2233
--------
@@ -40,6 +51,11 @@ Caching on user context works as follows:
4051
The appropriate user role dependent representation of ``/foo.php`` will
4152
then be returned to the client.
4253

54+
After this happened the first time, the hash can be cached by Varnish for this
55+
client, moving step 2-4 into the cache. After the page is in cache, subsequent
56+
requests from clients that got the same hash can be served from the cache as
57+
well.
58+
4359
Proxy Client Configuration
4460
--------------------------
4561

doc/varnish-configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ To make the hash request cacheable, you must extract a stable user session id
310310
If your application’s user authentication is based on a cookie other than
311311
PHPSESSID, change ``PHPSESSID`` to your cookie name.
312312

313+
.. _varnish_customttl:
314+
313315
Custom TTL
314316
~~~~~~~~~~
315317

0 commit comments

Comments
 (0)