Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.220 diff -u -F^f -r1.220 bootstrap.inc --- includes/bootstrap.inc 21 Aug 2008 19:36:36 -0000 1.220 +++ includes/bootstrap.inc 5 Sep 2008 20:23:13 -0000 @@ -634,6 +634,8 @@ function drupal_page_header() { * */ function drupal_page_cache_header($cache) { + global $user; + // Set default values: $last_modified = gmdate('D, d M Y H:i:s', $cache->created) . ' GMT'; $etag = '"' . md5($last_modified) . '"'; @@ -655,9 +657,28 @@ function drupal_page_cache_header($cache header("Last-Modified: $last_modified"); header("ETag: $etag"); - // The following headers force validation of cache: - header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); - header("Cache-Control: must-revalidate"); + if (variable_get('reverse_proxy', 0)) { + $cache_lifetime = variable_get('cache_lifetime', 0); + if (!$cache_lifetime) { + // If cache_lifetime is not set, then assume 15 minutes + $cache_lifetime = 900; + } + + // Set a cookie that indicates whether a user is logged in or not, this is used + // by the caching proxies + $logged_in = ($user->uid) ? 1 : 0; + setcookie('DRUPAL_LOGGED_IN', $logged_in, time() + $cache_lifetime, '/'); + + // The following headers makes for better caching for anonymous users when using + // reverse proxies such as Squid or Varnish + header("Expires: ". gmdate("D, d M Y H:i:s", time() + $cache_lifetime) ." GMT"); + header("Cache-Control: public, max-age=". $cache_lifetime); + } + else { + // Use the old header which do not get cached + header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); + header("Cache-Control: must-revalidate"); + } if (variable_get('page_compression', TRUE)) { // Determine if the browser accepts gzipped data. Index: sites/default/default.settings.php =================================================================== RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v retrieving revision 1.14 diff -u -F^f -r1.14 default.settings.php --- sites/default/default.settings.php 21 Aug 2008 19:36:39 -0000 1.14 +++ sites/default/default.settings.php 5 Sep 2008 20:23:13 -0000 @@ -268,6 +268,18 @@ * logging, statistics and access management systems; if you are unsure * about this setting, do not have a reverse proxy, or Drupal operates in * a shared hosting environment, this setting should remain commented out. + * + * Configuration for Squid + * acl cookie_logged_in req_header Set-Cookie DRUPAL_LOGGED_IN=1 + * cache deny cookie_logged_in + * acl cookie_logged_in_set req_header Cookie DRUPAL_LOGGED_IN=1 + * cache deny cookie_logged_in_set + * + * Configuration for Varnish + * if (req.http.Cookie && req.http.Cookie ~ "DRUPAL_LOGGED_IN=1") { + * pass; + * } + * */ # 'reverse_proxy' => TRUE, // Leave the comma here. /**