I have a somewhat complicated view that uses multiple displays for showing events. It uses a datepager (https://www.drupal.org/project/date_pager), exposed filters (using better exposed filters), and a local task menu.
The overall issue I'm having is that I want any event view link, be it a local task tab, a pagination link, or activating an exposed filter, to preserve any arguments in the URL. And because of a currently known bug for BEF, I can't even use the remember filters option.
So I've decided my best route is to go into the twig templates for these various pagers and menus, get the current arguments from the URL, and append or merge them as needed on the render links.
So far this seems to be working, but I'm running into an issue getting it to work well with the local task menu tabs.
I have a preprocess function in my theme file (using template_preprocess_menu_local_task) to get the arguments from the URL but the issue is that its caching and so if someone changes what filters they have selected the arguments don't update unless the cache is cleared.
I tried doing this:
$variables['element']['#cache']['max-age'] = 0;
but it didn't change anything.
Is there a way to turn off caching for local tasks from my custom theme?