You are here

README.txt in Dynamic Cache 7

Same filename and directory in other branches
  1. 6 README.txt
== DYNAMIC CACHE == 

-- Summary -- 

Dynamic Cache allows developers to dynamically disable Drupal's standard 
page cache for arbitrary conditions, by setting the global 
$conf['cache'] variable to CACHE_DISABLED (which is 0, or false) inside 
of their own module's hook_boot() implementation. 

Dynamic Cache does not include any user interface, it is intended for 
usage by module developers who wish to have more control over Drupal's 
standard caching behaviour. 

There is discussion of modifying core to allow this functionality 
natively here: "Allow hook_boot() to disable page cache" 
<http://drupal.org/node/322104>, but this has not even made it into D7, 
much less D6, which is why I decided to contribute this module, based on 
code from a live production site I developed, which enables this 
functionality immediately in D6. Hopefully a similar approach will be 
possible for D7, however this is not something I have investigated at 
this time. 

-- Usage -- 

Enable the module, then in your own custom module, in hook_boot(), you 
can set the global variable $conf['cache'] = CACHE_DISABLED, and this 
will properly disable Drupal's standard cache (it will not work for 
aggressive caching, which does not even invoke hook_boot). 

For example, you might want to disable page caching if the user has any 
items stored in "shopping cart" type session data. With the Dynamic 
Cache module enabled, you could use code similar to the following to 
make this happen: 

MYMODULE_boot(){ if( !empty( $_SESSION['cart_items'] ) ){ 
$GLOBALS['conf']['cache'] = CACHE_DISABLED; } } 

-- How It Works -- 

When the global cache variable is disabled, this module essentially 
"hijacks" the standard Drupal bootstrap process by never actually 
returning from hook_boot(); it completes the rest of the bootstrap 
process itself. 

There is a detailed description of this here: "Disable page caching 
conditionally, by hijacking the standard Drupal bootstrap process 
(working)" <http://drupal.org/node/875152> 

-- Important Note -- 

Because Dynamic Cache never returns from hook_boot(), it is critical 
that Dynamic Cache is executed AFTER any other modules that use 
hook_boot(). This means Dynamic Cache must be given a higher weight than 
all other modules which use hook_boot(). Dynamic Cache will install itself 
with a very high weight, but care should be taken to ensure no other boot 
modules are given a higher weight. Module weights can be inspected 
directly in the database's "system" table, or by using Util's Module 
Weights sub-module <http://drupal.org/project/util> 

-- Author/Maintainer -- 

Brian Cairns (brian_c) bcairns at gmail dot com

File

README.txt
View source
  1. == DYNAMIC CACHE ==
  2. -- Summary --
  3. Dynamic Cache allows developers to dynamically disable Drupal's standard
  4. page cache for arbitrary conditions, by setting the global
  5. $conf['cache'] variable to CACHE_DISABLED (which is 0, or false) inside
  6. of their own module's hook_boot() implementation.
  7. Dynamic Cache does not include any user interface, it is intended for
  8. usage by module developers who wish to have more control over Drupal's
  9. standard caching behaviour.
  10. There is discussion of modifying core to allow this functionality
  11. natively here: "Allow hook_boot() to disable page cache"
  12. , but this has not even made it into D7,
  13. much less D6, which is why I decided to contribute this module, based on
  14. code from a live production site I developed, which enables this
  15. functionality immediately in D6. Hopefully a similar approach will be
  16. possible for D7, however this is not something I have investigated at
  17. this time.
  18. -- Usage --
  19. Enable the module, then in your own custom module, in hook_boot(), you
  20. can set the global variable $conf['cache'] = CACHE_DISABLED, and this
  21. will properly disable Drupal's standard cache (it will not work for
  22. aggressive caching, which does not even invoke hook_boot).
  23. For example, you might want to disable page caching if the user has any
  24. items stored in "shopping cart" type session data. With the Dynamic
  25. Cache module enabled, you could use code similar to the following to
  26. make this happen:
  27. MYMODULE_boot(){ if( !empty( $_SESSION['cart_items'] ) ){
  28. $GLOBALS['conf']['cache'] = CACHE_DISABLED; } }
  29. -- How It Works --
  30. When the global cache variable is disabled, this module essentially
  31. "hijacks" the standard Drupal bootstrap process by never actually
  32. returning from hook_boot(); it completes the rest of the bootstrap
  33. process itself.
  34. There is a detailed description of this here: "Disable page caching
  35. conditionally, by hijacking the standard Drupal bootstrap process
  36. (working)"
  37. -- Important Note --
  38. Because Dynamic Cache never returns from hook_boot(), it is critical
  39. that Dynamic Cache is executed AFTER any other modules that use
  40. hook_boot(). This means Dynamic Cache must be given a higher weight than
  41. all other modules which use hook_boot(). Dynamic Cache will install itself
  42. with a very high weight, but care should be taken to ensure no other boot
  43. modules are given a higher weight. Module weights can be inspected
  44. directly in the database's "system" table, or by using Util's Module
  45. Weights sub-module
  46. -- Author/Maintainer --
  47. Brian Cairns (brian_c) bcairns at gmail dot com