diff --git a/README.txt b/README.txt index 98efe8059669d57d18e4cc873e5f9335ab8bb047..dd15005546fd3e01d8fa7519e1c07635550e190c 100644 --- a/README.txt +++ b/README.txt @@ -145,3 +145,5 @@ Post feature requests and bug reports to the issue tracking system at: CREDITS ------- Developed and maintained by Arto Bendiken +Ported to Drupal 5.x by Alexander I. Grafov +Miscellaneous contributions by: Jacob Peddicord, Justin Miller. diff --git a/boost.api.inc b/boost.api.inc index d16d53151438e175052bbb91b30908cf447dfea2..1f0cf59a575ef507b44ba7668dff5460b3127448 100644 --- a/boost.api.inc +++ b/boost.api.inc @@ -117,8 +117,11 @@ function boost_cache_get($path) { * Replaces the cached contents of the specified page, if stale. */ function boost_cache_set($path, $data = '') { - // Append the Boost footer with the current timestamp - $data = rtrim($data) . "\n" . str_replace('%date', date('Y-m-d H:i:s'), BOOST_BANNER); + // Append the Boost footer with the relevant timestamps + $time = time(); + $cached_at = date('Y-m-d H:i:s', $time); + $expires_at = date('Y-m-d H:i:s', $time + variable_get('cache_lifetime', 600)); + $data = rtrim($data) . "\n" . str_replace(array('%cached_at', '%expires_at'), array($cached_at, $expires_at), BOOST_BANNER); // Execute the pre-process function if one has been defined if (function_exists(BOOST_PRE_PROCESS_FUNCTION)) @@ -169,7 +172,7 @@ function boost_cache_directory($user_id = 0, $host = NULL) { * Returns the static file path for a Drupal page. */ function boost_file_path($path) { - if ($path == BOOST_FRONTPAGE) + if (empty($path) || $path == BOOST_FRONTPAGE) $path = 'index'; // special handling for Drupal front page return implode('/', array(boost_cache_directory(), $path)) . BOOST_FILE_EXTENSION; } diff --git a/boost.module b/boost.module index 4831921580851e13afcdc39a03e62261230b5458..44d5229463f698ffdebc5ec5be86d93b3078304f 100644 --- a/boost.module +++ b/boost.module @@ -29,7 +29,7 @@ define('BOOST_COOKIE', variable_get('boost_cookie', 'DRUPAL_UID')) // This line is appended to the generated static files; it is very useful // for troubleshooting (e.g. determining whether one got the dynamic or // static version): -define('BOOST_BANNER', variable_get('boost_banner', "\n")); +define('BOOST_BANNER', variable_get('boost_banner', "\n")); // This is needed since the $user object is already destructed in _boost_ob_handler(): define('BOOST_USER_ID', $GLOBALS['user']->uid); diff --git a/htaccess/boosted.txt b/htaccess/boosted.txt index f89b08425d387149d9df766be366feae58eceba4..9b37bffa5f9d878f050c9cb5ea9a213a6dc329e6 100644 --- a/htaccess/boosted.txt +++ b/htaccess/boosted.txt @@ -79,27 +79,37 @@ DirectoryIndex index.php #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$ #RewriteRule module.php index.php?q=%1 [L] - # Rewrite rules for static page caching provided by the Boost module + # Rewrite rules for static page caching provided by the Boost module: # BOOST START + + Header add Expires "Sun, 19 Nov 1978 05:00:00 GMT" + Header add Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0" + - AddCharset utf-8 .html + AddCharset utf-8 .html + RewriteCond %{REQUEST_METHOD} ^GET$ + RewriteCond %{REQUEST_URI} ^/$ + RewriteCond %{QUERY_STRING} ^$ + RewriteCond %{HTTP_COOKIE} !DRUPAL_UID + RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/index.html -f + RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/index.html [L] + RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{REQUEST_URI} !^/cache RewriteCond %{REQUEST_URI} !^/user/login RewriteCond %{REQUEST_URI} !^/admin - RewriteCond %{HTTP_COOKIE} !DRUPAL_UID - RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{QUERY_STRING} ^$ - RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI} -d - RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}/index.html -f + RewriteCond %{HTTP_COOKIE} !DRUPAL_UID + RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI} -d + RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}/index.html -f RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L] + RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{REQUEST_URI} !^/cache RewriteCond %{REQUEST_URI} !^/user/login RewriteCond %{REQUEST_URI} !^/admin - RewriteCond %{HTTP_COOKIE} !DRUPAL_UID - RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{QUERY_STRING} ^$ - RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}.html -f + RewriteCond %{HTTP_COOKIE} !DRUPAL_UID + RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0%{REQUEST_URI}.html -f RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L] # BOOST END