I am using the Context module with the Block module disabled and noticed that blocks are not being stored in the cache. How do I get Context to cache blocks? Does it matter that much that blocks are not being cached?

The block module is turned off because I don't see why it is needed with the Context module enabled. The block module loads every block on every page load. So I imagine that it would be a boost to use Context without it. However, I'm curious if it would make sense to also have the Context module cache each block that it loads and check the cache first before it loads the block.

  • Please clarify the question. Why are you turning off the Block module? Context has nothing to do with the Block cache.
    – Grayside
    Commented Jun 9, 2011 at 7:31
  • what version of Drupal?
    – ericduran
    Commented Jun 10, 2011 at 22:58
  • @ericduran Drupal 7
    – Adam S
    Commented Jun 10, 2011 at 23:10

3 Answers 3


How do I get Context to cache blocks?

Anyway a lot of block don't use cache by default. You need to use http://drupal.org/project/blockcache_alter to improve the control of what you want to cache. Sadly block cache alter is not compatible with context but a small glue module make it works :) http://drupal.org/project/context_blockcache_alter . But need a port on D7.

So using block cache alter going to do a real performance boost.

To not use block module the answer from Adam S is correct.

  • Thanks for this answer. This is valid for Drupal 6 only. Looks like context already works with blockcache_alter in drupal 7 so no longer needs the D7 port. Commented Nov 27, 2015 at 23:55

The Context module uses the Block module as an API. Context renders blocks with the Block module function, _block_render_blocks($region_blocks), which checks the cache. The Cache module looks for the table cache_block which if the block module has not been activated or has been uninstalled doesn't exist. In the case of the Context module installed and the Block module unistalled the cache_block table needs to exist to cache blocks.

The solution is to activate and then deactivate the Block module without uninstalling it. One less query and a few less loops on each page load now.


This is not a feature that is implemented in the context module, so you have some options.

  • Implement the feature yourself and post a patch.
  • Create a custom module that does the block caching for you.
  • Use panels instead of context which has it's own caching system built in.
  • Enable the block module.

Giving the block module a quick look, unsure what you mean when you're saying that the block module loads every block on every page. Have you tested how much overhead the block module do cause on your site? My guess is that it's not worth implementing your own caching to avoid having the block module enabled.


Having the block module enabled will create a little overhead, 1 query and some loops and boolean checks. This wouldn't be the place I'd start to performance optimize my site. Like I said probably not worth the hazzle implementing your own caching, but if you did you would get some performance improvement. Not sure if you could measure it though - I doubt it.

  • I must have misread this article because it seems that the blocks module just calls every block for a region and iterates through them to check the path for visibility. If there are no blocks in any regions, no blocks are loaded and the block module doesn't have to iterate through them. I would still like to know if any significant performance is gained with block module disabled. Since the Context module includes block.module I don't see why not have it cache the blocks.
    – Adam S
    Commented Jun 10, 2011 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.