Message-ID: <649043304.3996.1485856244660.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3995_1138116804.1485856244660" ------=_Part_3995_1138116804.1485856244660 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html HttpCache

HttpCache

=20 =20

Content Cache

 

eZ Platform uses Symfony HttpCache to = manage content "view" cache with an expiration model. In addition it is extended = (using FOSHttpCache) to add several advanced features. For content com= ing from the CMS the following is taken advantage of out of the box:

Cache and Expiration C= onfiguration

ezplatform.yml
=20
ezpublish:
    system:
        my_siteaccess:
            content:
                view_cache: true      # Activates HttpCache for content
                ttl_cache: true       # Activates expiration based HttpCach=
e for content (very fast)
                default_ttl: 60       # Number of seconds an Http response =
is valid in cache (if ttl_cache is true)
=20

Making your = controller response content-aware

Sometimes you need your controller's cache to be invalidated at the same= time as specific content changes (i.e. ESI sub-requests with render twig helper,= for a menu for instance). To be able to do that, you just need to add X-Location-Id header to the response object:

=20
use Symfony\Component\HttpFoundation\Response;
 
// Inside a controller action
// "Connects" the response to location #123 and sets a max age (TTL) of 1 h=
our.
$response =3D new Response();
$response->headers->set('X-Location-Id', 123);
$response->setSharedMaxAge(3600);
=20

Making your = controller response context-aware

If the content you're rendering depends on a user's permissions, then yo= u should make the response Context-aware:

=20
use Symfony\Component\HttpFoundation\Response;
 
// Inside a controller action
// Tells proxy configured to support this header to take the rights of a us=
er (user hash) into account for the cache
$response =3D new Response();
$response->setVary('X-User-Hash');
=20

 

 

------=_Part_3995_1138116804.1485856244660--