By pavanouce on
Hi Folks,
The problem i am having is all of blocks are being cached. How do I fix this.
Please help me on how to instruct drupal to cache specific blocks data.... Some of my blocks have dynamic data, and I want some of them to be cached...
Will the use of constants work like blocks[0]['cache'] = BLOCK_NO_CACHE / BLOCK_CACHE_GLOBAL
Comments
+1 to this....
+1 to this....
--
Works at Magazinul Cu Scule .ro
I do it in sql, not sure if
I do it in sql, not sure if it's the best, but it works.
The number is a sum of constants defined in block.module, i.e. for 'per user'+'per page' set to 6.
hook_block() gives a bunch of
hook_block() gives a bunch of different caching options:
BLOCK_CACHE_PER_ROLE (default): The block can change depending on the roles the user viewing the page belongs to.
BLOCK_CACHE_PER_USER: The block can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and should only be used when BLOCK_CACHE_PER_ROLE is not sufficient.
BLOCK_CACHE_PER_PAGE: The block can change depending on the page being viewed.
BLOCK_CACHE_GLOBAL: The block is the same for every user on every page where it is visible.
BLOCK_NO_CACHE: The block should not get cached.
Pick the one that works best for you.
Contact me to contract me for D7 -> D10/11 migrations.
Yes, it didn't work fro me
Yes, it didn't work fro me because I put it under wrong 'case' statement.
It should be in 'list':
Also I found Block Cache
Also I found a Block Cache Alter module.
[EDIT]
This module does it 'Drupal' way.