? boost-182686.patch Index: boost.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v retrieving revision 1.1.2.1.2.3.2.25 diff -u -p -r1.1.2.1.2.3.2.25 boost.admin.inc --- boost.admin.inc 9 Jun 2009 08:44:57 -0000 1.1.2.1.2.3.2.25 +++ boost.admin.inc 9 Jun 2009 09:01:51 -0000 @@ -114,6 +114,12 @@ function boost_admin_settings($form = ar '#maxlength' => 255, '#description' => t('If you are synchronizing the generated static cache files to an external server through some means such as SFTP or rsync, you can enter a shell command to be executed following a successful cron-triggered cache update. Note that this is an advanced setting that should normally be left blank.'), );*/ + $form['advanced']['boost_cache_xml'] = array( + '#type' => 'checkbox', + '#title' => t('Cache .xml & /feed'), + '#default_value' => BOOST_CACHE_XML, + '#description' => t('Boost will cache .xml and /feed urls as xml data.'), + ); $form['advanced']['boost_only_ascii_path'] = array( '#type' => 'checkbox', '#title' => t('Only allow ASCII characters in path'), @@ -246,20 +252,22 @@ function boost_admin_themes_submit($form /** * Generate htaccess code. - * + * * http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html * @param $server_name * %{SERVER_NAME} [OR] %{HTTP_HOST} [OR] www.example.com * @param $document_root * %{DOCUMENT_ROOT} [OR] getcwd() [OR] path to webroot from ~/ * @param $cache_dir - * cache + * cache dir * @param $gzip_dir - * gz + * gz dir * @param $html * html document file extention + * @param $xml + * xml document file extention */ -function boost_admin_generate_htaccess($server_name = '%{SERVER_NAME}', $document_root = '%{DOCUMENT_ROOT}', $cache_dir = 'cache', $gzip_dir = 'gz', $html = '.html') { +function boost_admin_generate_htaccess($server_name = '%{SERVER_NAME}', $document_root = '%{DOCUMENT_ROOT}', $cache_dir = 'cache', $gzip_dir = 'gz', $html = '.html', $xml = '.xml') { Global $base_path; $drupal_subdir = rtrim($base_path, '/'); $document_root = str_replace("\\", '/', $document_root); @@ -275,26 +283,35 @@ $document_root = str_replace($drupal_sub AddCharset utf-8 $html + AddCharset utf-8 $xml AddEncoding x-gzip .gz ForceType text/html + + AddEncoding x-gzip .gz + ForceType text/xml + # Skip boost IF not get request OR uri has wrong dir OR cookie is set RewriteCond %{REQUEST_METHOD} !^GET$ [OR] RewriteCond %{REQUEST_URI} (^$drupal_subdir(admin|cache|misc|modules|sites|system|themes))|(/(feed|comment/reply|user|user/(login|password|register))$) [OR] RewriteCond %{HTTP_COOKIE} DRUPAL_UID - RewriteRule .* - [S=2] + RewriteRule .* - [S=4] # GZIP RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond $document_root$drupal_subdir/$cache_dir/$gzip_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$html.gz -s RewriteRule .* $cache_dir/$gzip_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$html.gz [L] + RewriteCond $document_root$drupal_subdir/$cache_dir/$gzip_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$xml.gz -s + RewriteRule .* $cache_dir/$gzip_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$xml.gz [L,T=text/xml] # NORMAL RewriteCond $document_root$drupal_subdir/$cache_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$html -s RewriteRule .* $cache_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$html [L] + RewriteCond $document_root$drupal_subdir/$cache_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$xml -s + RewriteRule .* $cache_dir/$server_name%{REQUEST_URI}_%{QUERY_STRING}$xml [L,T=text/xml] ### BOOST END ### ETO; Index: boost.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v retrieving revision 1.3.2.2.2.5.2.50 diff -u -p -r1.3.2.2.2.5.2.50 boost.module --- boost.module 9 Jun 2009 08:00:22 -0000 1.3.2.2.2.5.2.50 +++ boost.module 9 Jun 2009 09:01:51 -0000 @@ -15,6 +15,7 @@ define('BOOST_ROOT_CACHE_PATH', 'ca define('BOOST_MULTISITE_SINGLE_DB', variable_get('boost_multisite_single_db', FALSE)); define('BOOST_FILE_PATH', BOOST_MULTISITE_SINGLE_DB ? boost_cache_directory(NULL, FALSE) : variable_get('boost_file_path', boost_cache_directory(NULL, FALSE))); define('BOOST_FILE_EXTENSION', variable_get('boost_file_extension', '.html')); +define('BOOST_XML_EXTENSION', variable_get('boost_xml_extension', '.xml')); define('BOOST_MAX_PATH_DEPTH', 10); define('BOOST_CACHEABILITY_OPTION', variable_get('boost_cacheability_option', 0)); define('BOOST_CACHEABILITY_PAGES', variable_get('boost_cacheability_pages', '')); @@ -29,6 +30,7 @@ define('BOOST_CLEAR_CACHE_OFFLINE', var define('BOOST_HALT_ON_ERRORS', variable_get('boost_halt_on_errors', FALSE)); define('BOOST_ROOT_FILE', variable_get('boost_root_file', '.boost')); define('BOOST_FLUSH_DIR', variable_get('boost_flush_dir', TRUE)); +define('BOOST_CACHE_XML', variable_get('boost_cache_xml', 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): @@ -401,6 +403,9 @@ function _boost_ob_handler($buffer) { if (_boost_get_content_type() == 'text/html') { boost_cache_set($GLOBALS['_boost_path'], $buffer); } + else if (_boost_get_content_type() == ('application/rss' || 'text/xml' || 'application/rss+xml')) { + boost_cache_set($GLOBALS['_boost_path'], $buffer, BOOST_XML_EXTENSION); + } } // Allow the page request to finish up normally @@ -460,12 +465,13 @@ function boost_is_cacheable($path) { if ( $normal_path == 'user' || preg_match('!^user/(login|register|password)!', $normal_path) || preg_match('!^admin!', $normal_path) - || preg_match('!/feed$!', $normal_path) - || preg_match('!\.xml$!', $normal_path) || preg_match('!comment/reply$!', $normal_path) ) { return FALSE; } + if (!BOOST_CACHE_XML && (preg_match('!/feed$!', $normal_path) || preg_match('!\.xml$!', $normal_path))) { + return FALSE; + } // Match the user's cacheability settings against the path if (BOOST_CACHEABILITY_OPTION == 2) { @@ -565,8 +571,9 @@ function boost_cache_expire_derivative($ * matching a wildcard. */ function boost_cache_expire($path, $wildcard = FALSE) { - $filenames = array(); - $filenames = glob(boost_file_path($path, FALSE, FALSE) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT); + $tempA = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_FILE_EXTENSION, GLOB_NOSORT); + $tempB = glob(boost_file_path($path, FALSE, NULL) . (($wildcard) ? '*' : '') . BOOST_XML_EXTENSION, GLOB_NOSORT); + $filenames = array_filter($tempA + $tempB); if (empty($filenames)) { return FALSE; } @@ -598,7 +605,7 @@ function boost_cache_get($path) { /** * Replaces the cached contents of the specified page, if stale. */ -function boost_cache_set($path, $data = '') { +function boost_cache_set($path, $data = '', $extension = BOOST_FILE_EXTENSION) { // Append the Boost footer with the relevant timestamps $time = time(); $cached_at = date('Y-m-d H:i:s', $time); @@ -619,7 +626,7 @@ function boost_cache_set($path, $data = db_set_active(); // Create or update the static files as needed - if (($filename = boost_file_path($path))) { + if (($filename = boost_file_path($path, TRUE, $extension))) { boost_cache_write($filename, $data); if (BOOST_GZIP) { boost_cache_write(str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename). '.gz', gzencode($data,9)); @@ -686,7 +693,7 @@ function boost_cache_directory($host = N * $extension * add extension to end of filename */ -function boost_file_path($path, $query = TRUE, $extension = TRUE) { +function boost_file_path($path, $query = TRUE, $extension = BOOST_FILE_EXTENSION) { //handling of url variables if ($GLOBALS['_boost_query'] != '_') { if ($query) { @@ -714,7 +721,7 @@ function boost_file_path($path, $query = } } - return implode('/', array(BOOST_FILE_PATH, $path . (($extension) ? BOOST_FILE_EXTENSION : ''))); + return implode('/', array(BOOST_FILE_PATH, $path . (is_null($extension) ? '' : $extension))); } /**