I want to display the date in a block and make sure that it is always up-to-date (i.e. not storing an old cached value).
Currently the date does not change, unless the cache is cleared ( via admin/config/development/performance or drush cr
)
It would appear that Drupal 8 does have a setting in the web admin UI for block caching, according to the question in: Has the Block Cache Settings from Drupal 8 been back-ported to Drupal 7?
Screenshot of the Drupal 8 block cache settings from that question:
However, the author of that question did not provide the specific URL path to this web UI admin settings (And I have asked them in the comments, linking to this question)
Can you advise where the block cache settings are in Drupal 8 and if it can turn off the cache for a block, please?
In my searching so far I have come across programmatic examples for switching off the cache.
I'm a developer and in the past for Drupal 8 I have done this programmatically for a custom block implemented in code in a custom module so I can but this approach would seem to be unnecessary extra work for turning off the cache for a particular block built in the UI (rather than in code). I would not like to have to add this for each particular block created in the UI.
Programmatic examples are:
Drupal 8 block cache (very similar to my problem)
Drupal 8: How do I invalidate cache for a block for anonymous users on a schedule?
Further information what am doing
I have implemented a custom block using today's date as a token via the blocks UI: admin/structure/block/block-content/types
and created a block type from this using admin/structure/block/block-content
and then placing it in the block structure using admin/structure/block
I am storing this as part of the config (yaml/yml) made possible using simple_block module which adds capability to store block config in the configuration system (so that I can import and export config as yaml drush cex
/ drush cim
. I am hoping that this turning off cache setting for a block cab be stored as config as well.
Thanks for reading and thanks your input.
cron
job in thecrontab
on my web server, to call Drupal cron. I will use this to clear the cache at midnight. I can set the cache programmatically as well. It's shame, though, this is gone as I can't see how my case would not be useful. I suppose I could write a contrib module to add on cache setting functionality and to make this exportable via config, in conjunction with simple_block module