How to cache block for logged in user?
Blocks are cached by default. A block class with this build method:

public function build() {
    return [
      '#markup' =&gt; 'Block content',
    ];
  }


gets cached indefinitely or as long as you set in cache max-age.

If you add cache tags to the block that doesn't change whether the block is cached or not. The cache tags are used to invalidate cache items, not to store them. That is what cache keys are used for.

If the block gets cached, this is for logged in users, because the cache for anonymous users doesn't cache blocks, only pages.