How do I make variables available for all blocks in a page? In my website I have an inc file containing some values that are needed on all blocks of a page. For reasons related to the performances, I would like not to use the php "require" function in each block. Is there a way to load this file at page level and make the values available in all blocks?

Do I have to do that in the template_preprocess function?
Yes this can be done in hook_preprocess_block.

inc file:

function get_some_vars() {
  static $vars = array();

  if (empty($vars)) {
    $vars['foo'] = expensive_function_1();
    $vars['bar'] = expensive_function_2();
  }

  return $vars;
}


.module/template.php file:

function MYMODULE_preprocess_block(&amp;$vars) {
  require_once 'my.inc'; // or module_load_include, depends where your code is

  $vars += get_some_vars();
}


It's not the exact desired workflow you described in the question, but it has a similar effect; require_once will only include the file once per request, and the variables will only be prepared once per request. There is the function call overhead, but given that themes don't have the concept of always-available-vars (as far as I know each theme call is an isolated instance as it were), I think this is the closest you'll get without patching the theme system.