--- includes/bootstrap.inc.core 2006-06-06 13:37:01.000000000 -0400
+++ includes/bootstrap.inc 2006-06-06 13:50:28.000000000 -0400
@@ -16,11 +16,12 @@
define('WATCHDOG_WARNING', 1);
define('WATCHDOG_ERROR', 2);
-define('DRUPAL_BOOTSTRAP_DATABASE', 0);
-define('DRUPAL_BOOTSTRAP_SESSION', 1);
-define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 2);
-define('DRUPAL_BOOTSTRAP_PATH', 3);
-define('DRUPAL_BOOTSTRAP_FULL', 4);
+define('DRUPAL_BOOTSTRAP_FILE', 0);
+define('DRUPAL_BOOTSTRAP_DATABASE', 1);
+define('DRUPAL_BOOTSTRAP_SESSION', 2);
+define('DRUPAL_BOOTSTRAP_PAGE_CACHE', 3);
+define('DRUPAL_BOOTSTRAP_PATH', 4);
+define('DRUPAL_BOOTSTRAP_FULL', 5);
// These values should match the 'role' table.
define('DRUPAL_ANONYMOUS_RID', 1);
@@ -149,7 +150,7 @@
* Loads the configuration and sets the base URL correctly.
*/
function conf_init() {
- global $db_url, $db_prefix, $base_url, $base_path, $base_root, $conf, $file_cache, $cache_lifetime;
+ global $db_url, $db_prefix, $base_url, $base_path, $base_root, $conf, $file_cache, $cache_lifetime, $file_cache_fastpath;
$conf = array();
require_once './'. conf_path() .'/settings.php';
@@ -823,6 +824,7 @@
*
* @param $phase
* A constant. Allowed values are:
+ * DRUPAL_BOOTSTRAP_FILE: initialize file-cache.
* DRUPAL_BOOTSTRAP_DATABASE: initialize database layer.
* DRUPAL_BOOTSTRAP_SESSION: initialize session handling.
* DRUPAL_BOOTSTRAP_PAGE_CACHE: load bootstrap.inc and module.inc, start
@@ -831,7 +833,7 @@
* data.
*/
function drupal_bootstrap($phase) {
- static $phases = array(DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL);
+ static $phases = array(DRUPAL_BOOTSTRAP_FILE, DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_SESSION, DRUPAL_BOOTSTRAP_PAGE_CACHE, DRUPAL_BOOTSTRAP_PATH, DRUPAL_BOOTSTRAP_FULL);
while (!is_null($current_phase = array_shift($phases))) {
_drupal_bootstrap($current_phase);
@@ -845,9 +847,19 @@
global $conf;
switch ($phase) {
- case DRUPAL_BOOTSTRAP_DATABASE:
+ case DRUPAL_BOOTSTRAP_FILE:
drupal_unset_globals();
+ // Initialize the configuration
conf_init();
+ // Display the page straight from the file cache if fastpath is enabled,
+ // unless the user is logged in or they have posted a form.
+ if ($file_cache_fastpath && !$_COOKIE['drupal_uid'] &&
+ $_POST == array()) {
+ drupal_file_cache();
+ }
+ break;
+
+ case DRUPAL_BOOTSTRAP_DATABASE:
// Initialize the default database.
require_once './includes/database.inc';
db_set_active();
--- modules/user.module.core 2006-06-06 13:50:46.000000000 -0400
+++ modules/user.module 2006-06-06 13:50:53.000000000 -0400
@@ -941,6 +941,12 @@
// Update the user table timestamp noting user has logged in.
db_query("UPDATE {users} SET login = %d WHERE uid = %d", time(), $user->uid);
+ // If the file_cache and file_cache_fastpath are both enabled, this cookie
+ // will be used to determine whether or not a user is logged in without
+ // actually loading all the session information from the database. It
+ // is valid for one month, and will be unset when the user logs out.
+ setcookie('drupal_uid', $user->uid, time() + (60 * 60 * 24 * 30), '/');
+
user_module_invoke('login', $form_values, $user);
$old_session_id = session_id();
@@ -1006,6 +1012,10 @@
watchdog('user', t('Session closed for %name.', array('%name' => theme('placeholder', $user->name))));
+ // This cookie is used by the file_cache to know when a user is logged in.
+ // We delete it by setting it to ''.
+ setcookie('drupal_uid', '');
+
// Destroy the current session:
session_destroy();
module_invoke_all('user', 'logout', NULL, $user);
--- modules/system.module.core 2006-06-06 13:50:58.000000000 -0400
+++ modules/system.module 2006-06-06 13:51:01.000000000 -0400
@@ -299,7 +299,7 @@
}
function system_view_general() {
- global $file_cache;
+ global $file_cache, $file_cache_fastpath;
// General settings:
$form['general'] = array(
@@ -391,18 +391,16 @@
'#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_ENABLED => t('Enabled')),
'#description' => t("Drupal has a caching mechanism which stores dynamically generated web pages by default to the database, or if configured in settings.php to the filesystem. By caching a web page, Drupal does not have to create the page each time someone wants to view it. Only pages requested by \"anonymous\" users are cached. In order to reduce server load and save bandwidth, Drupal stores and sends compressed cached pages.")
);
-
+ if ($file_cache && is_dir($file_cache)) {
+ $location = $file_cache_fastpath ? t('filesystem, fastpath enabled') : t('filesystem, fastpath disabled');
+ }
+ else {
+ $location .= t('database');
+ }
$form['cache']['location'] = array(
'#type' => 'item', '#title' => t('Cache location'),
- '#value' => (($file_cache && is_dir($file_cache)) ? t('filesystem') : t('database')),
- '#description' => t('By default, the Drupal cache is stored in the database. Alternatively, you may modify %settings, your Drupal configuration file, to have the cache stored as files in the filesystem. Additional information about this advanced cache configuration option can be found in settings.php.', array('%settings' => './'. conf_path() .'/settings.php'))
- );
-
- $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
- $period[0] = t('none');
- $form['cache']['cache_lifetime'] = array(
- '#type' => 'select', '#title' => t('Minimum cache lifetime'), '#default_value' => variable_get('cache_lifetime', 0), '#options' => $period,
- '#description' => t('Enabling the cache will offer a sufficient performance boost for most low-traffic and medium-traffic sites. On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.')
+ '#value' => $location,
+ '#description' => t('By default, the Drupal cache is stored in the database. Alternatively, you may modify %settings, your Drupal configuration file, to have the cache stored as files in the filesystem. Also in settings.php you may enable Drupal\'s filecache fastpath, telling Drupal to display cached pages without accessing the database. Additional information about these advanced cache configuration options can be found in settings.php.', array('%settings' => './'. conf_path() .'/settings.php'))
);
// File system:
--- sites/default/settings.php.core 2006-06-06 13:51:08.000000000 -0400
+++ sites/default/settings.php 2006-06-06 13:51:13.000000000 -0400
@@ -136,8 +136,29 @@
* Example:
* $file_cache = 'files/cache';
* $file_cache = '/tmp/cache';
+ *
+ * file_cache_fastpath:
+ * When file_cache_fastpath is enabled, pages that have been cached to the
+ * filesystem will be displayed to anonymous users without making any database
+ * queries. This bypasses Drupal's session management, as well as all _init
+ * and _exit hooks. As always, logged in users will not be displayed the
+ * cached pages.
+ *
+ * cache_lifetime:
+ * Simply enabling the page cache will offer a sufficient performance boost
+ * for most low-traffic websites. However, on high-traffic websites it can
+ * become necessary to enforace a minimum lifetime for cached pages. The
+ * cache_lifetime is the minimum amount of time that will go by before the
+ * cache is emptied and recreated. A larger minimum cache lifetime offers
+ * better performance, but users will not see new content for a longer period
+ * of time.
+ *
+ * The cache lifetime should be specified in seconds. By default there is no
+ * minimum cache lifetime.
*/
$file_cache = '';
+$file_cache_fastpath = FALSE;
+$cache_lifetime = 0;
/**
* PHP settings: