Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you include files[] = filecache.inc
in the .info file, users won't need to add $conf['cache_backends'] = array('sites/all/modules/contrib/filecache/filecache.inc');
to their settings file.
Comments
Comment #1
ogi CreditAttribution: ogi commentedfiles[]
are registered for autoloading in_drupal_bootstrap_database()
after_drupal_bootstrap_page_cache()
. File Cache should be available for page caching and this is one of the reasons whycache_backends
exists.Comment #2
patrickharris CreditAttribution: patrickharris commentedStrange - I was using it just for page caching successfully using this method.
Comment #3
ogi CreditAttribution: ogi commentedThis is interesting, I'll investigate it.
Anyway, adding
$conf['cache_default_class'] = 'DrupalFileCache';
tosettings.php
is still needed and so editingsettings.php
can't be avoided.Comment #4
patrickharris CreditAttribution: patrickharris commentedThese $conf variables can be set by
variable_set()
rather than hard coded in the settings.php file.I've written a filecache just for the page cache ('cache_page') which stores files like boost so pages are directly loaded by the server, and php isn't loaded. I just use
variable_set('cache_class_cache_page', 'MyFileCache');
in a module, and afiles[] = filecache.inc
in the .info file.Comment #5
ogi CreditAttribution: ogi commentedThe order of bootstrap phases is the following (defined in drupal_bootstrap()):
_drupal_bootstrap_page_cache checks if
page_cache_without_database
variable is set, and if it's not (this is the default), the following functions are invoked before continuing with page cache:drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
spl_autoload_register('drupal_autoload_class');
So what you suggest is true only for default settings but I want File Cache to be able to serve pages without DB and so it's better to use the intended way to do it, with
cache_backends
.Comment #6
patrickharris CreditAttribution: patrickharris commentedOh of course, if you want to avoid loading the DB it would have to be in settings - good point. Thanks for explaining that!
Comment #7
ogi CreditAttribution: ogi commentedOn second thought, it's a nice feature to just install filecache module and have a working File Cache. Less technical people need this, so this will be in 1.0. Just need to be careful to not filecache
cache_bootstrap
bin becauselookup_cache
cid contains autoloading info. And if there's any manual setting incache_*
variables, this automation should not be used.Thank you for this nice suggestion :-)
Comment #8
ogi CreditAttribution: ogi commentedComment #9
ogi CreditAttribution: ogi commentedNote to myself:
cache
bin should not be filecache:d too because automatedcache_*
variables are stored there.Comment #10
ogi CreditAttribution: ogi commentedThinking about this again, I see that avoiding editting of
settings.php
is not worth it.cache
andcache_bootstrap
bins can't be handled in this case and this devalues the whole idea of easy installation with major impact. AFAIK all other cache modules require editingsettings.php
.