This feature is available as of eZ Publish 5.2 / 2013.07
Being based on Symfony 2, eZ Publish 5 uses HTTP cache from version 5.0. However this cache management is only available for anonymous users due to HTTP restrictions.
It is of course possible to make HTTP cache vary thanks to the
Vary response header, but this header can only be based on one of the request headers (e.g.
Accept-Encoding). Thus, to make the cache vary on a specific context (e.g. a hash based on a user roles and limitations), this context must be present in the original request.
As the response can vary on a request header, the base solution is to make the kernel do a sub-request in order to retrieve the context (aka user hash). Once the user hash has been retrieved, it's injected in the original request in the
X-User-Hash custom header, making it possible to vary the HTTP response on this header:
This solution is implemented in Symfony reverse proxy (aka HttpCache) and is also accessible to dedicated reverse proxies like Varnish.
- Reverse proxy receives the HTTP request (without the user hash).
Reverse proxy does a sub-request (emulated in the case of HttpCache).
Sub-request must have the following headers:
- Original cookie (mainly to keep trace of the sessionId)
eZ Publish returns an HTTP response containing the user hash in
Reverse proxy adds the
X-User-Hashheader to the original request.
Note on performance
User hash is not generated for each
AUTHENTICATE request. It is cached using the
Cookie header string as key.
Hence each user has its own hash, generated once per session.
Hash generation being based by default on roles and limitations, a user can share the same hash with another one if their profile are similar. This is precisely what offers the possibility to share HTTP cache between several logged-in users.
You can customize user hash generation. Read How to customize UserHash generation in the developer cookbook to learn more about this.
Described behavior comes out of the box with Symfony reverse proxy, but it's of course possible ot use Varnish to achieve the same.
This can be done thanks to Varnish Curl vmod.