0
votes

I have a website running on Drupal 7. I have various blocks that appear throughout the site and contain:

  • PHP code
  • Views

Under Configuration –> Development both Caching options are unchecked:

  • Cache pages for anonymous users is unchecked
  • Cache blocks is unchecked

All the blocks that contain Views are not cached for authenticated and anonymous users (i.e. Every page request produces new results in the block). All the blocks that contain PHP code are cached for everyone (i.e Every page refresh uses the cached data and doesn;t execute the PHP code). The only way for these blocks to rerun the PHP code is Clear the Page Cache.

My questions are the following:

  1. Why are the blocks with the PHP code loaded from the Cache when the Caching options in the Configuration are unchecked?

  2. What is the most efficient way to disable cashing of all blocks?

*Please note that I don’t want to use Javascript/jQuery/Ajax instead of PHP.

1

1 Answers

0
votes

Hm, it could be a problem with the php filter which (maybe in some older drupal 7 versions, don't know if this happens also in newer ones) has the cache set in the filter_format table. You can have a better description here: https://www.drupal.org/node/1424698#comment-8719155

If this will fix the issue, I would actually suggest to implement a hook_filter_info_alter(): https://api.drupal.org/api/drupal/modules!filter!filter.api.php/function/hook_filter_info_alter/7 and for the php_code filter set the cache to FALSE:

if (!empty($info['php_code'])) {
 $info['php_code']['cache'] = FALSE;
}