Check if cache is active I would like to set some functionality in a module only on if caching is turned off.

Is there a way to check in code if caching is on or off?
The "Cache pages for anonymous users" setting is stored in the variable table (as a 0 or 1), you can get it like this:

if (variable_get('cache', 0)) {
  // Cache is turned on
}


If you're interested in the "Cache blocks" setting it's also in the variables table and you can get it like this:

if (variable_get('block_cache', 0)) {
  // Block cache is turned on
}


Just for reference the first is defined in system_performance_settings() and the second in block_form_system_performance_settings_alter().