From 15cb27671e5b0f7626e3d3b5a0166fb6e068bcc6 Mon Sep 17 00:00:00 2001 From: Lorenz Schori Date: Wed, 9 Jan 2013 16:12:12 +0100 Subject: [PATCH] Add option to exclude caching of admin pages based on path_is_admin --- authcache.admin.inc | 8 ++++++++ authcache.helpers.inc | 5 +++++ authcache.module | 1 - 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/authcache.admin.inc b/authcache.admin.inc index 6f450c8..d15555b 100644 --- a/authcache.admin.inc +++ b/authcache.admin.inc @@ -155,6 +155,7 @@ function authcache_admin_config_submit($form, &$form_state) { variable_set('authcache_pagecaching', array(array( 'option' => 0, 'pages' => AUTHCACHE_NOCACHE_DEFAULT, + 'noadmin' => 1, 'roles' => $cache_roles, ))); } @@ -240,6 +241,12 @@ function _authcache_pagecache_form($details) { '#description' => $description, '#default_value' => $details['pages'], ); + $form['fieldset']['noadmin'] = array( + '#type' => 'checkbox', + '#title' => t('Exclude Admin pages'), + '#description' => t('Do not cache administrative pages.'), + '#default_value' => $details['noadmin'], + ); $form['fieldset']['roles'] = array( '#title' => 'Apply to these roles', '#type' => 'checkboxes', @@ -356,6 +363,7 @@ function authcache_admin_pagecaching_submit($form, &$form_state) { array( 'option' => 0, 'pages' => AUTHCACHE_NOCACHE_DEFAULT, + 'noadmin' => 1, 'roles' => $cache_roles, ), ) diff --git a/authcache.helpers.inc b/authcache.helpers.inc index 3c2a000..34f8289 100644 --- a/authcache.helpers.inc +++ b/authcache.helpers.inc @@ -117,6 +117,11 @@ function _authcache_is_cacheable() { default: break; } + + if (!empty($page_rules['noadmin']) && path_is_admin(current_path())) { + $is_cacheable = FALSE; + $_authcache_info['no_cache_reason'] = 'Not caching admin pages'; + } } $i++; } diff --git a/authcache.module b/authcache.module index 1c0b67b..52cb57f 100644 --- a/authcache.module +++ b/authcache.module @@ -26,7 +26,6 @@ civicrm* cart* system/files/* system/temporary* -admin/* '); // Default non-HTML caching rules (don't append JS to page content) -- 1.7.10.4