ESI for selective caching
Here is the definition of ESI according to Wikipedia:
"Edge Side Includes or ESI is a small markup language for edge level dynamic web content assembly. The purpose of ESI is to tackle the problem of web infrastructure scaling. Dynamic content creates a problem for caching systems. To overcome this problem a group of companies developed the ESI specification and submitted it to the W3C for approval." | ||
--Wikipedia |
In simple words, we can use ESI to define independent caching rules for any section of each page. Again, Symfony comes with out-of-the-box support for the ESI feature. We don't need to install anything to use ESI in our project. All we need to do is uncomment the following line in config.yml
:
# app/config/config.yml # ... framework: esi:
Then, we need to wrap the part of the template that we want to have a different caching strategy for in an ESI renderer. Thanks to Twig, we can easily do this as follows:
# src/Resources/views/Dashboard/index...