3

I am using a Kohana minifier module to compress less/ css and js files into type combined files.

/less/f31e419e939bfec51b4fe8322f545455.less?r=20130618 /js/24dae189814109f20ff9a5bf4422be36.js?r=20130618

I am using MAMP PRO but receive the following error on Firefox and Chrome:

Content Encoding Error
This webpage is not available

The content headers are coming through as:

HTTP/1.1 200 OK
Date: Tue, 18 Jun 2013 11:17:14 GMT
Server: Apache
X-Powered-By: PHP/5.4.4
Etag: "acf11d952c07adb223fa77f3d385f56e"
Cache-Control: must-revalidate
Last-Modified: Thu, 13 Jun 2013 21:57:04 +0000
Content-Encoding: gzip
Content-Length: 16894
Set-Cookie: session_database=ecfc139402165669a4b6d5e8190564231133fb0d%7E51c041ba9f6e95-28008580; expires=Wed, 19-Jun-2013 11:17:17 GMT; path=/
Content-Type: text/css; charset=utf-8

The content works if I remove the gzip encoding but obviously I would like to take advantage of the gzip compression. My PHP code is:

// Further up the page
$data['cache_gz'] = gzencode($data['cache']);

//...

if ($gzip === FALSE){
    $this->response->body($data['cache']); // Works
}else{
    this->response->headers('Content-Encoding', $gzip); // Doesn't Work

    $this->response->headers('Content-Length', strlen($data['cache_gz']));
    $this->response->body($data['cache_gz']);
}

Would really appreciate some guidance with this as I am stumped as to how to solve this issue or if it is just related to being on a local server.

AltDan
  • 844
  • 4
  • 13
  • 27
  • Did enable mod_deflate on your local apache? – herrhansen Jun 20 '13 at 07:52
  • Yes all of the modules are load including mod_deflate – AltDan Jun 21 '13 at 19:13
  • 1
    on php.net manpage of gzencode function. One comment suggests to add ini_set('zlib.output_compression','Off'); before gzencode. And why you use gzencode(...) even if gzip flag is False ? – 0xBAADF00D Jul 17 '13 at 21:08
  • Ensure all error messages are turned off, with white spaces eliminated from file endings and beginnings, also ensure that mod_deflate is not re-encoding the already encoded data. – tlogbon Jul 23 '13 at 20:29

2 Answers2

0

Try http://php.net/manual/ru/function.gzcompress.php It may help you, like it helped me one time :))

Serge Velikan
  • 1,131
  • 15
  • 31
0

This may just be a typo in your post, but

this->response->headers('Content-Encoding', $gzip);

should be

$this->response->headers('Content-Encoding', $gzip);
Kevin Ji
  • 10,479
  • 4
  • 40
  • 63