? boost-520600.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.72
diff -u -p -r1.3.2.2.2.5.2.72 boost.module
--- boost.module	15 Jul 2009 07:48:30 -0000	1.3.2.2.2.5.2.72
+++ boost.module	16 Jul 2009 09:37:21 -0000
@@ -398,7 +398,7 @@ function boost_block($op = 'list', $delt
                 '<strong>The cached copy expired %interval ago.</strong>' :
                 'The cached copy will expire in %interval.',
                 array('%interval' => format_interval(abs($ttl))));
-              $output .=  drupal_get_form('boost_block_form');
+              $output .=  drupal_get_form('boost_block_flush_form');
             }
             $error = FALSE;
             if (function_exists('error_get_last')) {
@@ -415,6 +415,7 @@ function boost_block($op = 'list', $delt
                 $output .= t(' MESSAGES: %msg <br /> !performance', array('%msg' => $drupal_msg, '!performance' => l(t('Turn Off Error Checking'), 'admin/settings/performance')));
               }
             }
+            $output .=  drupal_get_form('boost_block_db_settings_form');
 
             $block['subject'] = '';
             $block['content'] = theme('boost_cache_status', isset($ttl) ? $ttl : -1, $output);
@@ -456,23 +457,63 @@ function boost_block($op = 'list', $delt
   }
 }
 
-function boost_block_form() {
-  $form['clear_cache']['path'] = array(
+function boost_block_flush_form() {
+  $form['boost_clear']['path'] = array(
     '#type' => 'hidden',
     '#value' => $GLOBALS['_boost_path'],
   );
-  $form['clear_cache']['clear'] = array(
+  $form['boost_cache']['clear'] = array(
     '#type' => 'submit',
     '#value' => t('Flush Page'),
-    '#submit' => array('boost_block_form_submit'),
+    '#submit' => array('boost_block_form_flush_submit'),
   );
   return ($form);
 }
 
-function boost_block_form_submit(&$form_state, $form) {
+function boost_block_form_flush_submit(&$form_state, $form) {
   boost_cache_expire_derivative($form['values']['path'], TRUE);
 }
 
+function boost_block_db_settings_form() {
+  // set info
+  $period = drupal_map_assoc(array(-1, 0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 64800, 86400, 2*86400, 3*86400, 4*86400, 5*86400, 6*86400, 604800, 2*604800, 3*604800, 4*604800, 8*604800, 16*604800, 52*604800), 'format_interval');
+  $period[0] = '<' . t('none') . '>';
+  $period[-1] = t('default');
+  $info = boost_get_db(boost_file_path($GLOBALS['_boost_path']));
+  if (!$info) {
+    $info['lifetime'] = -1;
+    $info['push'] = -1;
+  }
+
+  // create form
+  $form['boost_db_settings']['lifetime'] = array(
+    '#type' => 'select',
+    '#title' => t('Minimum cache lifetime'),
+    '#default_value' => $info['lifetime'],
+    '#options' => $period,
+    '#description' => t('Default: %default', array('%default' => format_interval(BOOST_CACHE_LIFETIME))),
+  );
+  $form['boost_db_settings']['push'] = array(
+    '#type' => 'hidden',
+    '#title' => t('Preemptive Cache'),
+    '#default_value' => $info['push'],
+    '#options' => array(-1 => 'default', 0 => 'No', 1 => 'Yes'),
+  );
+  $form['boost_db_settings']['send'] = array(
+    '#type' => 'submit',
+    '#value' => t('Set Configuration'),
+    '#submit' => array('boost_block_db_settings_form_submit'),
+  );
+  return $form;
+}
+
+/**
+ * Sets page specific settings in the boost cache database.
+ */
+function boost_block_db_settings_form_submit(&$form_state, $form) {
+  boost_set_db_page_settings($form['values']['lifetime'], $form['values']['push']);
+}
+
 /**
  * Generate js/html for boost stat counter.
  *
@@ -935,12 +976,14 @@ function boost_cache_set($path, $data = 
  *
  * @param $filename
  *   Name of cached file; primary key in database
+ * @param $lifetime
+ *   Number of seconds page lasts before it is considered stale
+ * @param $push
+ *   Should this page be crawled right after it is expired.
  */
-function boost_db_prep($filename) {
+function boost_db_prep($filename, $lifetime = -1, $push = -1) {
   $router_item = _boost_get_menu_router();
   $expire = BOOST_CACHE_LIFETIME + BOOST_TIME;
-  $lifetime = -1;
-  $push = -1;
 
   $boost_settings_db = boost_get_settings_db($router_item);
   $boost_db = boost_get_db($filename);
@@ -982,6 +1025,35 @@ function boost_put_db($filename, $expire
 }
 
 /**
+ * Sets per page configuration.
+ *
+ * @param $lifetime
+ *   Default lifetime
+ * @param $push
+ *   Pre-cache this file
+ */
+function boost_set_db_page_settings($lifetime, $push) {
+  $router_item = _boost_get_menu_router();
+  $filename = boost_file_path($GLOBALS['_boost_path']);
+  $info = boost_get_db($filename);
+  if (!$info) {
+    $info['expire'] = 0;
+  }
+  elseif ($lifetime == -1) {
+    $info['expire'] = $info['expire'] - $info['lifetime'] + BOOST_CACHE_LIFETIME;
+  }
+  elseif ($info['lifetime'] == -1) {
+    $info['expire'] = $info['expire'] - BOOST_CACHE_LIFETIME + $lifetime;
+  }
+  elseif ($info['lifetime'] != $lifetime) {
+    $info['expire'] = $info['expire'] - $info['lifetime'] + $lifetime;
+  }
+
+  //boost_cache_expire_derivative($GLOBALS['_boost_path']);
+  boost_put_db($filename, $info['expire'], $lifetime, $push, $router_item);
+}
+
+/**
  * Gets boost info from cache database.
  *
  * @param $filename
