0

main.phpHTMLマークアップを圧縮するために、Yiiの構成ファイルにこのコードを追加しました

'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'
4

3 に答える 3

3

yii レベルで html コードを縮小したほうがよい

.htaccess でこのようなセグメントを使用して、gzip 圧縮を apache に残す

<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>
于 2012-07-19T22:21:57.363 に答える
1

これは PHP 5.4 のバグです: https://bugs.php.net/bug.php?id=62335

次のような方法で無効にする必要があるzlibかもしれません:

<?php ini_set('zlib.output_compression', 'Off'); ?>
于 2012-07-19T16:27:00.310 に答える
0

Apache 用の Google pagespeed モジュールは私と連携しており、dreamhost といくつかの Web ホスティングにプリインストールされています。

https://developers.google.com/speed/pagespeed/module

于 2015-01-13T15:03:40.497 に答える