This module allows website administrators to easily adjust the cache settings for individual blocks directly through the administrative interface. It provides a user-friendly way to configure cache metadata like expiration time, contexts, and tags without needing to write custom code.
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:
Ask your assistant about Blocache (Block Cache Control)
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
- block Drupal core
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.