- Modified version of patch #121820 by Caleb et al: add an option for page compression.

6.x
Dries Buytaert 2007-10-25 15:38:25 +00:00
parent 1cf05b0019
commit ca0bbfee5b
4 changed files with 22 additions and 11 deletions

View File

@ -607,13 +607,15 @@ function drupal_page_cache_header($cache) {
header("Expires: Sun, 19 Nov 1978 05:00:00 GMT");
header("Cache-Control: must-revalidate");
// Determine if the browser accepts gzipped data.
if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) {
// Strip the gzip header and run uncompress.
$cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
}
elseif (function_exists('gzencode')) {
header('Content-Encoding: gzip');
if (variable_get('page_compression', TRUE)) {
// Determine if the browser accepts gzipped data.
if (@strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') === FALSE && function_exists('gzencode')) {
// Strip the gzip header and run uncompress.
$cache->data = gzinflate(substr(substr($cache->data, 10), 0, -8));
}
elseif (function_exists('gzencode')) {
header('Content-Encoding: gzip');
}
}
// Send the original request's headers. We send them one after

View File

@ -673,14 +673,15 @@ function fix_gpc_magic() {
* @endcode
*
* - @variable, which indicates that the text should be run through check_plain,
* to strip out HTML characters. Use this for any output that's displayed within
* to escape HTML characters. Use this for any output that's displayed within
* a Drupal page.
* @code
* drupal_set_title($title = t("@name's blog", array('@name' => $account->name)));
* @endcode
*
* - %variable, which indicates that the string should be highlighted with
* theme_placeholder() which shows up by default as <em>emphasized</em>.
* - %variable, which indicates that the string should be HTML escaped and
* highlighted with theme_placeholder() which shows up by default as
* <em>emphasized</em>.
* @code
* $message = t('%name-from sent %name-to an e-mail.', array('%name-from' => $user->name, '%name-to' => $account->name));
* @endcode
@ -2391,7 +2392,7 @@ function page_set_cache() {
// This will fail in some cases, see page_get_cache() for the explanation.
if ($data = ob_get_contents()) {
$cache = TRUE;
if (function_exists('gzencode')) {
if (variable_get('page_compression', TRUE) && function_exists('gzencode')) {
// We do not store the data in case the zlib mode is deflate.
// This should be rarely happening.
if (zlib_get_coding_type() == 'deflate') {

View File

@ -1189,6 +1189,13 @@ function system_performance_settings() {
'#options' => $period,
'#description' => t('On high-traffic sites it can become necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will go by before the cache is emptied and recreated. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time. This setting also affects block caching.')
);
$form['page_cache']['page_compression'] = array(
'#type' => 'radios',
'#title' => t('Page compression'),
'#default_value' => variable_get('page_compression', TRUE),
'#options' => array(t('Disabled'), t('Enabled')),
'#description' => t("By default Drupal compresses the pages it caches in order to save bandwidth, and improve download times for users with slow connections. However, if the webserver also performs compression, it is not just unnecessary, it can also cause problems. So in this case this option should be set to Disabled."),
);
$form['block_cache'] = array(
'#type' => 'fieldset',

View File

@ -943,6 +943,7 @@ function system_settings_form_submit($form, &$form_state) {
drupal_set_message(t('The configuration options have been saved.'));
}
cache_clear_all();
drupal_rebuild_theme_registry();
}