2012-07-19 37 views
0

我对Yii中添加以下代码到CONFIGRATION文件main.php压缩HTML标记Yii with ob_gzhandler;压缩HTML

'preload'=>array('log'), 
    'onBeginRequest' => create_function('$event', 'return ob_start("ob_gzhandler");'), 
    'onEndRequest' => create_function('$event', 'return ob_end_flush();'), 

,但我有zlib的冲突如何解决呢?

ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' 

回答

1

它是用PHP 5.4中的错误:https://bugs.php.net/bug.php?id=62335

你可能需要的东西,如可能禁用zlib

<?php ini_set('zlib.output_compression', 'Off'); ?> 
+0

我可以禁用形式htaccess,但仍HTML不压缩 – Abudayah 2012-07-19 16:29:19

+0

我m使用mod_pagespeed现在很棒 – Abudayah 2014-03-03 19:05:48

3

你在警予水平有了更好的缩小 HTML代码

通过在.htaccess中使用这样的片段将gzip压缩到apache中.htaccess

<IfModule deflate_module> 
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/json application/javascript 

# Netscape 4.x has some problems... 
BrowserMatch ^Mozilla/4 gzip-only-text/html 

# Netscape 4.06-4.08 have some more problems 
BrowserMatch ^Mozilla/4\.0[678] no-gzip 

# MSIE masquerades as Netscape, but it is fine 
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html 

# Do NOT compress localhost 
#SetEnvIf Remote_Host 127.0.0.1 no-gzip 

# Make sure proxies don't deliver the wrong content 
Header append Vary User-Agent env=!dont-vary 
</IfModule>