There is a variable 'page_cache_without_database' which is rather handy in that it can force Drupal to use page cache from settings.php, but it is rather poorly named. If you look at the code in bootstrap.inc where it is used you'll see that if you are using regular database caching this variable will (despite its name) actually enable database caching:
// Check for a cache mode force from settings.php.
if (variable_get('page_cache_without_database')) {
$cache_enabled = TRUE;
}
else {
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES, FALSE);
$cache_enabled = variable_get('cache');
}
drupal_block_denied(ip_address());
// If there is no session cookie and cache is enabled (or forced), try
// to serve a cached page.
if (!isset($_COOKIE[session_name()]) && $cache_enabled) {
// Make sure there is a user object because its timestamp will be
// checked, hook_boot might check for anonymous user etc.
$user = drupal_anonymous_user();
// Get the page from the cache.
$cache = drupal_page_get_cache();
// If there is a cached page, display it.
This function appears to do two things, enable cache, and not load variables from the database. However, that isn't really what its name implies. Am I wrong in how this functions?
Comments
Comment #1
marcingy CreditAttribution: marcingy commentedNothing is broken so this is a task and needs to be fixed in d8 first
Comment #2
joachim CreditAttribution: joachim commented'cache_enabled_pre_bootstrap'?
Comment #3
soyarma CreditAttribution: soyarma commentedOne other note that I did discover is that if you use this variable Drupal does not output cachable headers (which means things like varnish won't cache the page). You still have to check off the caching checkbox on the performance page to get that :S
Comment #4
joachim CreditAttribution: joachim commentedCould also probably do with some documentation in settings.php.
Comment #5
znerol CreditAttribution: znerol commentedMaking this a sub-issue of #2257695: [meta] Modernize the page cache
Comment #6
mgiffordMaybe it will... cache_enabled_pre_bootstrap doesn't deal with not loading variables, but that might not matter.
Comment #7
Berdir#2368987: Move internal page caching to a module to avoid relying on config get on runtime will remove this setting. And I don't see how something like this would be backported, so closing as duplicate.