Leafiny Documentation
Cache
There are 4 types of cache.
Config
Module configuration files (etc/config.php
) are concatened and stored as a json file.
When you add or edit a configuration, the config cache must be flushed if enabled.
Enabled the cache
In the global configration file (e.g.: /etc/config.default.php
), set 1 for the config_cache key:
'app' => [
/* ... */
'config_cache' => 1,
/* ... */
],
Flush the cache
Flush cache from the admin (Admin > Cache > Configuration) or remove the config cache directory: var/cache/config
.
Templates
The template cache is a compilation cache directory, where Twig caches the compiled templates to avoid the parsing phase for sub-sequent requests.
When you add or edit a twig template file, the template cache must be flushed if enabled.
Enabled the cache
In the global configration file (e.g.: /etc/config.default.php
), set 1 for the twig_cache key:
'app' => [
/* ... */
'twig_cache' => 1,
/* ... */
],
Flush the cache
Flush cache from the admin (Admin > Cache > Templates) or remove the template cache directory: var/cache/twig
.
FPC
The Full Page Cache allows to store the final generated twig template. When the template file exists, it is opened instead of the original page template.
The FPC avoids to run the child blocks PHP code each time the page is opened. However, it is possible to define dynamic blocks in the page. Leafiny offers a FPC system where the whole template is cached, except some areas (like Varnish with esi).
Note: The FPC allows to run code before rendering the template, for example in the page action method.
The dynamic blocks are specified in the template with a nocache comment directive:
<!-- nocache::'catalog.menu' -->{{ child('catalog.menu') }}<!-- /nocache::'catalog.menu' -->
This catalog.menu block will always be rendered dynamically.
You can use variables with the block:
<!-- nocache::'catalog.menu',{"var":page.getMyVar} -->{{ child('catalog.menu', {"var":page.getMyVar}) }}<!-- /nocache::'catalog.menu' -->
Enabled the cache
In the global configration file (e.g.: /etc/config.default.php
), set 1 for the default page fpc key:
'page' => [
'default' => [
/* ... */
'fpc' => 1,
/* ... */
],
],
Here the FPC is enabled for all the pages, but it can be specifically disabled:
'page' => [
'/hello.html' => [
/* ... */
'fpc' => 0,
/* ... */
],
],
Flush the cache
Flush cache from the admin (Admin > Cache > FPC) or remove the template cache directory: var/cache/fpc
.
Autoload
To avoid that the autoload always looks for a class in the module directories, a symlink is added in a directory when the class is found.
When a class is removed or renamed in a module, you should flush the autoload cache.
Enabled the cache
The autoload cache system is always enabled. There is no option to disable it.
Flush the cache
Flush cache from the admin (Admin > Cache > Autoload) or remove the autoload directory: var/load
.