Disable cache of a custom block
Although it is not recommended, it is possible to disable the cache of a custom block. You can use it, for example, when you are developing a custom block in your module and while you are making changes you want to reflect the changes by refreshing the page, avoiding having to clear Drupal caches.
Enter the following code snippet in your custom block
public function getCacheMaxAge() {
// Disable block cache.
return 0;
}