'textarea', '#title' => t('Pages to exclude from caching'), '#default_value' => variable_get('cacheexclude_list', ''), '#description' => t('The pages listed here will be cleared from cache immediatly after generation. Enter one Drupal path (URL aliases are not supported) per line. The character \'*\' can be used as wildcard. Example paths are \'blog\' for the blog page and \'blog/*\' for every personal blog.'), ); } } /** * Implementation of hook_exit(). */ function cacheexclude_exit($destination = NULL) { global $base_root; if ($destination == NULL) { // get current Drupal path $currentpath = $_GET['q']; // get and iterate over patterns $patterns = explode("\n", variable_get('cacheexclude_list', '')); foreach ($patterns as $pattern) { $pattern = trim($pattern); if ($pattern) { // rewrite pattern to preg pattern $pattern = '/^' . preg_replace('/\\\\\*/', '.*', preg_quote($pattern, '/')) . '$/'; // try pattern if (preg_match($pattern, $currentpath)) { cache_clear_all($base_root . request_uri(), 'cache_page'); return; } } } } }