I'm working on a module in Drupal 8 which retrieves time sensitive data from an external REST api. The data is processed and forwarded to a Block. The final data is sent to a Twig template like so:
...
public function build() {
$build = [];
$build['ticker_block'] = [
'#theme' => 'module_theme',
'#data' => $myService->data(),
];
return $build;
}
This doesn't work on the production environment where cache is enabled and the rendered data shows up as stale. How do I disable cache for my module only, and do I have to do it for both the Twig template and Block plugin?