Closed (fixed)
Project:
Similar By Terms
Version:
6.x-1.4
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
2 Jul 2008 at 05:35 UTC
Updated:
23 Oct 2011 at 09:58 UTC
I need a way to exclude these blocks from Drupal's block cache. I've seen some use of BLOCK_NO_CACHE, but I am unsure where and how to apply it to the module. Any ideas?
Comments
Comment #1
rmiddle commented1. Block_No_cache is only needed in Drupal 6. Drupal 5 doesn't have a block cache.
2. This could harmer your system pretty hard.
3. Edit the module and change the following lines.
else if ($op == 'view') {
$block['cache'] = BLOCK_NO_CACHE; // <-- Insert this line.
if ($delta == 0) {
$block['subject'] = t('Similar');
4. You will have to clear out your blocks table before it will take effect. For more info on that #235673: Changes to block caching mode not caught.
Based on the example on the top of that ticket. Add this to the install script
function similarterms_update_0702() {
$ret = array();
db_query('UPDATE {blocks} SET cache=-1 WHERE module=\'similarterms\'');
return $ret;
}
***** Use of this code will cause an increase in system load..
Can I ask why you need it to not be cached?
Thanks
Robert
Comment #2
Rob T commentedSay I have 3 terms in the vocabulary fruit: apples, oranges, lemons. Each of these terms has hundreds of nodes.
With Drupal 6.2 block cache turned on... the Similar by Terms block looks as if it is cache-ing just one term, "apples" (or whatever the first term in that vocabulary's usage after a cache clear). So when I visit an "orange" or "lemon" node, the Similar by Terms block for the Fruit vocabulary only shows nodes related to "apples".
When you say this could harm my system, how bad are you talking? I've found that the block cache provides me with significant speed enhancements, so I'd like to be able to take advantage of that feature.
Comment #3
rmiddle commentedRob T,
I think this might be a bug in simliarterm / drupal 6.2. As for the load issue. Drupal 5 didn't include a cache on the blocks so if your system ran fine under 5 it should run fine under 6 without a cache. I need to change this to a bug report. A nasty one at that.
Thanks
Robert
Comment #4
rmiddle commentedComment #5
Rob T commentedThanks for the attention. Yes, the site runs fairly well without block cache, but it's noticeably faster with it turned on.
Wouldn't a BLOCK_NO_CACHE utilization like the one you provided provide a workable solution for those like me who wish to maintain cacheing of other blocks (and not similarterm)? If there was ever a use for BLOCK_NO_CACHE, I'd think this module - similarterm - would warrant it.
Until a solution develops, yes... I will go without the cache. But I sure am tempted to try your BLOCK_NO_CACHE usage suggestion.
Comment #6
rmiddle commentedRob T,
The issue is bigger. Adding the code in to turn off the cache for the block is no big deal. The problem is that Drupal 6 doesn't record the change in cache settings. So if you installed a version before the patch it wouldn't fix the issue. You would have to clear you block cache and I am not sure there is an automated way to do that. There is a patch in drupal core but wont be released until 6.3 is released.
Thanks
Robert
Comment #7
rmiddle commentedFixed in 6.x-1.5, Will still effect people with Drupal 6.2 and less and who already had the module installed.
Thanks
Robert
Comment #8
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #9
MakeOnlineShop commentedHello,
On an DRUPAL UBERCART shop, do you know how I could exclude CART BLOCK from caching for anonymous users ?
Because this block doesn't show cart content for anonymous users.
Thank you so much for your help.