summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boost.admin.inc6
-rw-r--r--boost.module25
2 files changed, 31 insertions, 0 deletions
diff --git a/boost.admin.inc b/boost.admin.inc
index 263752b..7453904 100644
--- a/boost.admin.inc
+++ b/boost.admin.inc
@@ -275,6 +275,12 @@ function boost_admin_boost_performace_page() {
'#default_value' => BOOST_FLUSH_DIR,
'#description' => t('Disable this if you have to set settings for each dir/subdir, due to the way your server opperates (permissions, etc...).'),
);
+ $form['advanced']['boost_flush_node_terms'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Flush all cached terms pages associted with a node on insert/update/delete'),
+ '#default_value' => BOOST_FLUSH_NODE_TERMS,
+ '#description' => t('Works with view\'s taxonomy/term/% path as well as core.'),
+ );
$form['advanced']['boost_overwrite_file'] = array(
'#type' => 'checkbox',
'#title' => t('Overwrite the cached file if it already exits'),
diff --git a/boost.module b/boost.module
index 3ff024d..4487183 100644
--- a/boost.module
+++ b/boost.module
@@ -46,6 +46,7 @@ define('BOOST_PERMISSIONS_DIR', variable_get('boost_permissions_dir', ''));
define('BOOST_OVERWRITE_FILE', variable_get('boost_overwrite_file', FALSE));
define('BOOST_DISABLE_CLEAN_URL', variable_get('boost_disable_clean_url', FALSE));
define('BOOST_VERBOSE', variable_get('boost_verbose', 5));
+define('BOOST_FLUSH_NODE_TERMS', variable_get('boost_flush_node_terms', TRUE));
// This cookie is set for all authenticated users, so that they can be
// excluded from caching (or in the future get a user-specific cached page):
@@ -327,6 +328,18 @@ function boost_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
}
boost_cache_expire_derivative('node/' . $node->nid, TRUE);
}
+
+ // get terms and flush their page
+ if (BOOST_FLUSH_NODE_TERMS) {
+ $terms = taxonomy_node_get_terms(node_load($node->nid));
+ $filenames = array();
+ foreach($terms as $term) {
+ $filenames = array_merge($filenames, boost_get_db_term($term->tid));
+ }
+ foreach($filenames as $filename) {
+ boost_cache_kill($filename);
+ }
+ }
break;
}
}
@@ -1321,6 +1334,18 @@ function boost_get_settings_db($router_item) {
}
/**
+ * Returns all cached pages asscoited with the taxonomy term.
+ */
+function boost_get_db_term($term) {
+ $filenames = array();
+ $result = db_query("SELECT filename FROM {boost_cache} WHERE expire > 0 AND page_id = %d AND page_callback = 'taxonomy'", $term);
+ while ($filename = db_fetch_array($result)) {
+ $filenames[] = $filename['filename'];
+ }
+ return $filenames;
+}
+
+/**
* Writes data to filename in an atomic operation thats compatible with older
* versions of php (php < 5.2.4 file_put_contents() doesn't lock correctly).
*