Hi,

Since hook_init is not run on pages that are already cached, I was wondering if a validation or submission callback should be created for the settings form so that the the cache can be cleared on the specified pages. That way, the admin does not have to go to the performance page if they see an issue that a page that was cached is showing up a certain way.

-BTM

Comments

Crell’s picture

That makes sense. I'm not sure when I'll have a chance to roll a patch, but if someone else wants to I'd commit it.

btmash’s picture

Assigned: Unassigned » btmash

I should be able to get a patch around on wednesday or thursday of this week (no access to my set of code for testing till then :()

btmash’s picture

Status: Active » Needs review

I don't have it in patch format, but I'm wondering if this would be the way to go about it...

function cacheexclude_admin_settings() {
  $form['cacheexclude_list'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages to exclude from caching'),
    '#default_value' => variable_get('cacheexclude_list', ''),
    '#width' => 40,
    '#height' => 10,
    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
  );
  $form = system_settings_form($form);
  $form['#submit'][] = 'cacheexclude_admin_settings_submit';
  return $form;

}

function cacheexclude_admin_settings_submit($form, &$form_state) {
  cache_clear_all(NULL, 'cache_page', '*');
}
greg.harvey’s picture

Crell’s picture

Status: Needs review » Active

There's no patch here.

It's probably better for performance to do a complete flush when the settings change than to add a boot hook. boot hooks can be quite expensive since they require stating another file.

mbutcher’s picture

BTMash's suggestion has been coded up and committed. It will be available in 6.x-2.1.

mbutcher’s picture

Assigned: btmash » mbutcher
Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.