How can I turn off the caching for a Paragraph type? I'm rendering an array whose URL is dependent on a $_GET variable.
Where the variable is present and valid, I want to serve an iframe with the _GET variable as part of the URL. At the moment the cache is capturing the variable and preventing different value being passed to the page.
In my module I have this:
function MY_MODULE_preprocess_paragraph__iframe(&amp;$variables) {
    $query = @$_GET['e'];
    /*...*/
}

But the value $query is staying the same until the caches are cleared.
Is there a better way of capturing the $_GET variable, or a way of preventing the value from being cached?
Declare the dependency on the GET parameter with a cache context:
/mymodule/mymodule.module
function mymodule_preprocess_paragraph(&amp;$variables) {

  $foo = \Drupal::request()-&gt;query-&gt;get('foo');
  $variables['content']['foo'] = [
    '#markup' =&gt; &quot;foo = $foo&quot;,
    '#cache' =&gt; ['contexts' =&gt; ['url.query_args:foo']],
  ];
}

More info https://www.drupal.org/docs/drupal-apis/cache-api/cache-contexts
However, if you have more than a few possible values of foo this is a problem with cache performance, especially for nested entities like paragraphs. Each value creates a new cache entry for the paragraph and its parent entities.
To avoid this put a placeholder in the paragaph:
/mymodule/mymodule.module
function mymodule_preprocess_paragraph(&amp;$variables) {
  
  $variables['content']['foo_placeholdered'] = [ 
    '#lazy_builder' =&gt; ['\Drupal\mymodule\MymoduleLazyBuilders::getFoo', []],
    '#create_placeholder' =&gt; TRUE,
  ];
}

and build the content which depends on the GET parameter in a lazy builder:
/mymodule/src/MymoduleLazyBuilders.php
&lt;?php

namespace Drupal\mymodule;

use Drupal\Core\Render\Element\RenderCallbackInterface;

class MymoduleLazyBuilders implements RenderCallbackInterface {

  public static function getFoo() {
    $foo = \Drupal::request()-&gt;query-&gt;get('foo');
    return  [
      '#markup' =&gt; &quot;foo = $foo&quot;,
      '#cache' =&gt; ['contexts' =&gt; ['url.query_args:foo']],
    ];
  }

}

For time consuming calculations such placeholders can be delivered through BigPipe. So if you enable this module you can also improve page speed.