summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/application/config/config.php22
-rw-r--r--system/libraries/Output.php14
2 files changed, 32 insertions, 4 deletions
diff --git a/system/application/config/config.php b/system/application/config/config.php
index 7b19b83b5..e88abd9f9 100644
--- a/system/application/config/config.php
+++ b/system/application/config/config.php
@@ -204,7 +204,6 @@ $config['log_date_format'] = 'Y-m-d H:i:s';
*/
$config['cache_path'] = '';
-
/*
|--------------------------------------------------------------------------
| Encryption Key
@@ -216,7 +215,6 @@ $config['cache_path'] = '';
*/
$config['encryption_key'] = "";
-
/*
|--------------------------------------------------------------------------
| Session Variables
@@ -236,7 +234,6 @@ $config['sess_table_name'] = '';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
-
/*
|--------------------------------------------------------------------------
| Cookie Related Variables
@@ -262,5 +259,24 @@ $config['cookie_path'] = "/";
*/
$config['global_xss_filtering'] = FALSE;
+/*
+|--------------------------------------------------------------------------
+| Output Compression
+|--------------------------------------------------------------------------
+|
+| Enables output compression using Gzip for faster page loads. When enabled,
+| the output class will test whether the server your site is running on
+| supports Gzip. Even if it does, however, not all browsers support compression
+| so enable only if you are reasonably sure your visitors can handle it.
+|
+| VERY IMPORTANT: If you are getting a blank page when this is enabled it
+| means you are prematurely outputing something to your browser. It could
+| even be a line of whitespace at the end of one of your scripts. For
+| compression to work, nothing can be sent before the output buffer is called
+| by the output class.
+|
+*/
+$config['compress_output'] = TRUE;
+
?> \ No newline at end of file
diff --git a/system/libraries/Output.php b/system/libraries/Output.php
index b09bf2a53..4a3adb858 100644
--- a/system/libraries/Output.php
+++ b/system/libraries/Output.php
@@ -86,7 +86,6 @@ class CI_Output {
{
$this->headers[] = $header;
}
-
// --------------------------------------------------------------------
@@ -145,6 +144,19 @@ class CI_Output {
$output = str_replace('{memory_usage}', $memory, $output);
$output = str_replace('{elapsed_time}', $elapsed, $output);
+ // Is compression requested?
+ $CFG =& _load_class('CI_Config');
+ if ($CFG->item('compress_output') === TRUE)
+ {
+ if (extension_loaded('zlib'))
+ {
+ if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
+ {
+ ob_start('ob_gzhandler');
+ }
+ }
+ }
+
// Are there any server headers to send?
if (count($this->headers) > 0)
{