Invalidating Paragraph Cache
You've got a logic error in your PHP. You're doing the following and setting some variables:

$variables['elements']['#cache']['max-age'] = '0';
$variables['elements']['#cache']['contexts'][] = 'url.path';
$variables['elements']['#cache']['contexts'][] = 'url.query_args:r';


But then in the next line you're redeclaring $variables['elements']['#cache'] as a new array of  ['tags' =&gt; ['my_paragraph']]; So everything you were doing previously in the 
$variables['elements']['#cache'] is now gone

So your max-age declaration doesn't exist now. Try with just these 2 items and that should be all you need. The first to tell drupal not to cache the paragraph. The 2nd to disable anonymous page caching as setting max-age 0 doesnt disable the page cache:

$variables['elements']['#cache']['max-age'] = '0';
\Drupal::service('page_cache_kill_switch')-&gt;trigger();