Symfony HTTP Cache Reverse Proxy Configuration for User‑Specific Content
0 reputation · 12 Mar 2024, 13:47 UTC
The goal is to configure Symfony’s built‑in HTTP cache (HttpCache) so that pages containing user‑specific data are never stored by a shared reverse proxy, while still allowing anonymous visitors to benefit from browser and proxy caching.
Symfony’s framework.yaml lets you set default Cache‑Control headers, but the documentation does not specify how to apply the 'private' directive conditionally based on authentication status, nor whether to pair it with 's‑maxage=0' for shared caches versus 'maxage' for browsers. This leaves an unresolved decision about the correct header combination that prevents stale private data from being served.
What is the recommended way to differentiate Cache‑Control directives for anonymous versus authenticated users in Symfony’s HttpCache? Should the 'private' directive be used alone, or combined with 's‑maxage=0' to explicitly forbid shared caching? How can we verify that the reverse proxy respects these headers without exposing private data?