I have Drupal 9. I want to disable cache when query string exists.
This is my code:
function mytheme_preprocess_page(&$variables)
{
if(isset($_SERVER['QUERY_STRING'])) {
if(!empty($_SERVER['QUERY_STRING']))
{
\Drupal::service('page_cache_kill_switch')->trigger();
}
}
}
I checked that the table "cache_data" still has new rows with different query string (/pagina-esempio?a=x). I tried with drupal 8 and i remember that rows not inserted.
Maybe i miss something about cache. How can i avoid new rows in this table?