https://drupal.stackexchange.com/questions/223376/what-is-the-correct-way-to-set-cache-contexts-on-custom-blocks
---------
public function build() {
$search_form = Drupal::formBuilder()->getForm('DrupalmymoduleFormSearchForm');
return [
'#theme' => 'mycustomtemplate',
'#search_form' => $search_form,
'#cache' => ['contexts' => ['url.path', 'url.query_args']]
];
}
{% block content %}
{{ content }}
{% endblock %}