The extension is a filter to compress the HTML output - to reduce bandwidth.
The filter offers two compression methods:
Heads up: The GZIP compression is turned off for old buggy IE's (< IE7).
See the following code example:
GZIP for all actions
/** * @return array action filters */ public function filters() { return array( array( 'application.filters.html.ECompressHtmlFilter', 'gzip' => (YII_DEBUG ? false : true), 'doStripNewlines' => (YII_DEBUG ? false : true), 'actions' => '*' ), ); }
GZIP only for index & admin action in controller with CRUD actions
/** * @return array action filters */ public function filters() { return array( array( 'application.filters.html.ECompressHtmlFilter', 'gzip' => (YII_DEBUG ? false : true), 'doStripNewlines' => (YII_DEBUG ? false : true), 'actions' => 'index, admin' ), ); }
Trim leading white space, blank lines & new lines from HTML output for all action
/** * @return array action filters */ public function filters() { return array( array( 'application.filters.html.ECompressHtmlFilter', 'gzip' => false, 'actions' => 'ALL' ), ); }
Nothing will compressed
/** * @return array action filters */ public function filters() { return array( array( 'application.filters.html.ECompressHtmlFilter', ), ); }
Total 3 comments
Can this be used in base
Controller(descent ofCController) class, placed inprotected/components, with'actions' => '*'and thus enable GZIP compression of any output application will generate (any controller and any action)? Or does it have to be put in every controller separately?@Porcelanosa not if you're on a shared webhosting
gzip_deflate almost alwayst turn on in apache - and it gziped all files automatically
Leave a comment
Please login to leave your comment.