Content Cache
eZ Publish uses Symfony HttpCache to manage content "view" cache with the expiration model.
An additional X-Location-Id header is added in the response for identification (for details see cache purge document).
Configuration
Cache and Expiration Configuration for error pages
It is normal to want to set the default_ttl
setting above high to have a high cache hit ratio on your installation. As the system takes care of purges, the cache rarely becomes stale.
However, a few redirect and error pages are served via the ContentView system, and if you do set a high default_ttl
, you should make sure to set those pages to a much lower ttl to avoid issues caused by that. For this you can use the FOSHttpCacheBundle matching rules feature to specify a different ttl time:
Similarly, if you want to apply performance tuning to avoid crawlers affecting the setup too much, you can also set up caching of generic 404's and similar error pages in the following way:
Making your controller content cache aware
Sometimes you need that your controller's cache expires in the same time than a specific content (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:
Making your controller user cache aware
If the content you're rendering depends on the user permissions, then an additional header must be set for this as explained in Context aware HTTP cache