How to disable/enable cache of all views programmatically? Case: I have over 50 views in my site and for performance improvement all were enabled to cache data during their implementation.

Now I want to disable cache for all views at once for some reason (make it more realtime).

Please help.
You could switch them all off with features and a bit of hacking. Also, as this involves changing lots of things in mass, make sure you back up your work before doing it and make sure you test it out on a dev server first.  

With features, you can create a feature containing just your views. You can then download this feature, which will give you something that looks a lot like a module file. 

One of the files in this module will be a file called your_feature.views_default.inc, which will contain a bunch of code that will look ALOT like a view export script (because that's exactly what it is.) 

If you look at the lines of code, they each represent a configuration in your views, you should be have a bunch of lines that looks like:

  $handler-&gt;display-&gt;display_options['cache']['type'] = 'time';
  $handler-&gt;display-&gt;display_options['cache']['results_lifespan'] = '3600';
  $handler-&gt;display-&gt;display_options['cache']['results_lifespan_custom'] = '0';
  $handler-&gt;display-&gt;display_options['cache']['output_lifespan'] = '3600';
  $handler-&gt;display-&gt;display_options['cache']['output_lifespan_custom'] = '0';


depending how you set your caching. Regardless, if you want to shut off caching on all your views, all of those lines need to become:

$handler-&gt;display-&gt;display_options['cache']['type'] = 'none';


One your edits are done, save the file and upload the feature module back up to your site in your sites/all/modules folder. 

Once it's uploaded, head back to your site, and head to the features admin at admin/structure/features, you should see your feature hanging out there, and it's state should be "Overridden." Click on "Overridden," and you see the overview of your feature, along with a handy-dandy button on the lower right hand of the screen that says "revert components." Click the checkbox next to the views list (to tell features what you want reverted), and then click on the revert components to revert the views to what is stored in code. 

Now, there is a down side to using this method. The way features works is it actually takes your view and stores it in code, not the DB. So removing your feature would actually remove you views as well. This will be true until you edit your view, in which case it would go back in the database (just that one view though, not all of them).