@@ -11,6 +11,10 @@ The FOSHttpCache library includes a solution to cache responses per user
1111context (whether the user is authenticated, groups the user is in, or other
1212information), rather than individually.
1313
14+ If every user has their own hash, you probably don't want to cache at all. Or
15+ if you found out its worth it, vary on the credentials and don't use the
16+ context hash mechanism.
17+
1418.. caution ::
1519
1620 Whenever you share caches, make sure to not output any individual content
@@ -47,8 +51,22 @@ Currently, user context caching is only supported by Varnish and by the Symfony
4751HttpCache. See the :ref: `Varnish Configuration <varnish user context >` or
4852:ref: `Symfony HttpCache Configuration <symfony-cache user context >`.
4953
54+ User Context Hash from Your Application
55+ ---------------------------------------
56+
57+ It is your application's responsibility to determine the hash for a user. Only
58+ your application can know what is relevant for the hash. You can use the path
59+ or the accept header to detect that a hash was requested.
60+
61+ .. warning ::
62+
63+ Treat the hash lookup path like the login path so that anonymous users also
64+ can get a hash. That means that your cache can access the hash lookup even
65+ with no user provided credential and that the hash lookup never redirects
66+ to a login page.
67+
5068Calculating the User Context Hash
51- ---------------------------------
69+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5270
5371The user context hash calculation (step 3 above) is managed by the HashGenerator.
5472Because the calculation itself will be different per application, you need to
@@ -65,7 +83,7 @@ Once all providers are registered, call ``generateHash()`` to get the hash for
6583the current user context.
6684
6785Context Providers
68- -----------------
86+ ~~~~~~~~~~~~~~~~~
6987
7088Each provider is passed the :source: `UserContext <src/UserContext/UserContext.php> `
7189and updates that with parameters which influence the varied response.
@@ -93,7 +111,7 @@ A provider that looks at whether the user is authenticated could look like this:
93111.. _return context hash :
94112
95113Returning the User Context Hash
96- -------------------------------
114+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
97115
98116It is up to you to return the user context hash in response to the hash request
99117(``/_fos_user_context_hash `` in step 3 above)::
0 commit comments