Disable caching for custom block for anonymous users
The problem is, you don't render the block in a normal way and Display Suite is obviously not able to retrieve the plugin cache metadata. 

Most times it is a better option to include the cache metadata in the render array together with the data it depends on:

public function build() {
  $build = [];
  $request = \Drupal::request();
  $mode = $request-&gt;query-&gt;get('mode');
  $build['mode'] = [
    '#markup' =&gt; t('The query argument is mode=@mode.', ['@mode' =&gt; $mode]),
  ];
  $build['#cache']['contexts'][] = 'url.query_args:mode';
  return $build;
}


Then the cache metadata can bubble up, no matter where and how this block content is embedded.