How to prevent a block from being cached?
Got the solution via https://stefvanlooveren.me/blog/disable-block-caching-drupal-8

Add below function to your block

https://stefvanlooveren.me/blog/disable-block-caching-drupal-8

public function getCacheMaxAge() {
    return 0;
}


https://www.drupal.org/docs/8/api/cache-api/cache-max-age