Blocache (Block Cache Control)
Summary: this module allows website builders to change the block cache metadata through the administrative block interface (see attached images). Learn more about cache metadata here.
- - - - - -
In Drupal 8, blocks, as well as pages, are built from the idea of rendering arrays. Rendering arrays determine what is shown to the user. Therefore, arrays also determine how cacheable an answer is. This is done using the #cache key, for example:
$build = [
...
'#cache' => [
'max-age' => 600,
'tags' => ['user: administer'],
'contexts' => ['user'],
],
...
];
Cacheability metadata consists of 3 properties:
max-age — for time-sensitive caching, i.e. time dependencies;
contexts — for variations, i.e. dependencies on the request context;
tags — for dependencies on data managed by Drupal, like entities & configuration.
Core modules and community modules determine the values for this metadata. In addition, Drupal currently does not provide the possibility to change block cache metadata from the graphical interface, only by implementing specific hooks.
If you do not like the default set, you can install this module and easily change the settings through the graphical interface. After installing this module, the configuration form for each block will display a set of fields called Cache Settings, where you can configure the cache metadata as you see fit.
Installation
Install as you would normally install a contributed Drupal module, for example:
$ composer require 'drupal/blocache:^2.0'
View Installing Modules for further information.
Maintainers
Developed and maintained by:
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.