How do I redirect to an external URL without caching it?
Disable caching in responses

You can build the cacheable metadata and put max-age = 0 in it:

$build = [
  '#cache' =&gt; [
    'max-age' =&gt; 0,
  ],
];
$cache_metadata = \Drupal\Core\Cache\CacheableMetadata::createFromRenderArray($build);
$response-&gt;addCacheableDependency($cache_metadata);


If you want to put this in one line:

$response
 -&gt;addCacheableDependency((new \Drupal\Core\Cache\CacheableMetadata())-&gt;setCacheMaxAge(0));


Disable caching for anonymous requests

Also you have to disable the page cache for anonymous requests

\Drupal::service('page_cache_kill_switch')-&gt;trigger();


This is necessary no matter if you use a normal redirect response or one with drupal caching.