I work on a Drupal/Pressflow-based platform, serving multiple sites off one codebase.
We do not use the built-in Block admin system. Instead, we use Context to place Blocks within regions on all our pages. So, the Blocks are all 'disabled' in the Block system.
Our page load performance is pretty abysmal for our sites, which do not get a lot of traffic - maybe tens of thousands of pageviews a day. Use of Varnish has given us some oxygen to breathe but on our dev servers (no caching turned on) you see page loads taking 10-30 seconds each for some of our sites. That's pretty terrible.
Trying various caching schemes improves some performance, but not with Views Blocks. The SQL queries get run EVERY SINGLE TIME the page loads, regardless of cache settings: Page, Block, Views Block Cache, Views Data Caching. It's like Views Blocks completely ignore the rest of the Drupal system.
I downloaded and installed Block Cache Alter and Context Block Cache Alter to see if I could finally wrest control of these blocks.
It isn't working. Based on a two year-old post from this thread on Block Cache Alter -- #455328 -- I added the debug code into both BCA and CBCA modules. I went into Block configuration for my Views Blocks and tried Global and per Page settings. Because there is no formal documentation for this module, I have to assume that this module only enhances BCA to work within Contexts - there seems to be no admin interface in addition to BCA's.
the function '_context_blockcache_alter_build_block' is run, and when you get to the line:
if ($cacheable && ($cid = _blockcache_alter_get_cache_id($block->module, $block->delta))) {
The value for $cacheable is '1' but the $cid value is NULL,meaning the block has not been cached, so the block gets built with
$array = module_invoke('blockcache_alter', 'block', 'view', $block->module . ',' . $block->delta);
which I would assume would then cache the result so that the next time I reload the page, the block is cached, but that isn't happening. The SQL queries for all Views Blocks are being run every single time. Because these queries sort on joined cck fields, they are taking over 2 seconds to return results in some cases.
Is there some additional setting I am missing here? Do I need to make some additional settings changes directly in Views? in Context? in Blocks? Or, is my issue really a Block Cache Alter issue? I'm not sure because I am unclear as to exactly what this module is doing to make block caching work within Context. Any light someone could shine on this would be greatly appreciated.
Many thanks.
Comments
Comment #1
ccshannon commentedARGH, I found the problem, and it's in Block Cache Alter:
The 'delta' field in blocks is NOT an integer. Views stores the delta as a string, not an integer. "block.delta" is a varchar(32) type field, so this line should be:
Wow, now my blocks are caching!
Comment #2
bastnic commentedMaybe you should post this bug on the Block Cache Alter module? Everywhere in the file, they are using %s, it's just in _blockcache_alter_get_cache_id that they use %d.
Comment #3
ccshannon commentedThanks. Yes, actually, I found it in the Block Cache Alter issues queue already, but it is a 'closed' issue and, therefore, harder to find.
Here it is: #730334: Cache value for blocks with string deltas is not loaded correctly
Comment #4
bastnic commentedBlockcache_alter fixed it, closing this ticket.